UBER-316 Date picker is not editable by keyboard (#3283)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-05-30 14:42:02 +06:00 committed by GitHub
parent adda89d0c6
commit 3910f2d1f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,8 +105,10 @@
edits = edits edits = edits
} }
export const isNull = (currentDate: Date | null, full: boolean = false): boolean => { export const isNull = (currentDate: Date | null | undefined = undefined, full: boolean = false): boolean => {
dateToEdits(currentDate) if (currentDate !== undefined) {
dateToEdits(currentDate)
}
let result: boolean = false let result: boolean = false
edits.forEach((edit, i) => { edits.forEach((edit, i) => {
if (edit.value === -1 && full && i > 2) result = true if (edit.value === -1 && full && i > 2) result = true
@ -134,7 +136,7 @@
} else { } else {
edits[index].value = edits[index].value * 10 + num edits[index].value = edits[index].value * 10 + num
} }
if (!isNull(currentDate, false) && !startTyping) { if (!isNull() && !startTyping) {
fixEdits() fixEdits()
currentDate = setValue(edits[index].value, currentDate, ed) currentDate = setValue(edits[index].value, currentDate, ed)
dateToEdits(currentDate) dateToEdits(currentDate)
@ -148,7 +150,7 @@
else if (selected === 'hour' && (shouldNext || edits[3].value > 2)) selected = 'min' else if (selected === 'hour' && (shouldNext || edits[3].value > 2)) selected = 'min'
} }
if (ev.code === 'Enter') { if (ev.code === 'Enter') {
if (!isNull(currentDate, false)) dispatch('close') if (!isNull(currentDate)) dispatch('close')
} }
if (ev.code === 'Backspace') { if (ev.code === 'Backspace') {
edits[index].value = -1 edits[index].value = -1