mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Fix shortcut keys prevented in date fields (#5009)
This commit is contained in:
parent
341815cc03
commit
55dadf0b00
@ -81,6 +81,16 @@ describe('DateComponent', () => {
|
||||
expect(eventSpy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should show allow system keyboard events', () => {
|
||||
let event: KeyboardEvent = new KeyboardEvent('keypress', {
|
||||
key: '9',
|
||||
altKey: true,
|
||||
})
|
||||
let preventDefaultSpy = jest.spyOn(event, 'preventDefault')
|
||||
input.dispatchEvent(event)
|
||||
expect(preventDefaultSpy).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should support paste', () => {
|
||||
expect(component.value).toBeUndefined()
|
||||
const date = '5/4/20'
|
||||
@ -99,5 +109,25 @@ describe('DateComponent', () => {
|
||||
event['clipboardData'] = clipboardData
|
||||
input.dispatchEvent(event)
|
||||
expect(component.value).toEqual({ day: 4, month: 5, year: 2020 })
|
||||
// coverage
|
||||
window['clipboardData'] = {
|
||||
getData: (type) => '',
|
||||
}
|
||||
component.onPaste(new Event('foo') as any)
|
||||
})
|
||||
|
||||
it('should set filter button title', () => {
|
||||
component.title = 'foo'
|
||||
expect(component.filterButtonTitle).toEqual(
|
||||
'Filter documents with this foo'
|
||||
)
|
||||
})
|
||||
|
||||
it('should emit date on filter', () => {
|
||||
let dateReceived
|
||||
component.value = '12/16/2023'
|
||||
component.filterDocuments.subscribe((date) => (dateReceived = date))
|
||||
component.onFilterDocuments()
|
||||
expect(dateReceived).toEqual([{ day: 16, month: 12, year: 2023 }])
|
||||
})
|
||||
})
|
||||
|
@ -90,7 +90,11 @@ export class DateComponent
|
||||
}
|
||||
|
||||
onKeyPress(event: KeyboardEvent) {
|
||||
if ('Enter' !== event.key && !/[0-9,\.\/-]+/.test(event.key)) {
|
||||
if (
|
||||
'Enter' !== event.key &&
|
||||
!(event.altKey || event.metaKey || event.ctrlKey) &&
|
||||
!/[0-9,\.\/-]+/.test(event.key)
|
||||
) {
|
||||
event.preventDefault()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user