composebox_typeahead: Fix bug in global time backspace & delete cases.

In the previous commit (bea41e975d) we
introduced a bug by using `hotkey` instead of `hotkey.name`, further
debugging revealed that the conditional was unnecessary and as such
has been removed in this commit, the comment for the is_numeric
conditional has also been changed to explain its actual purpose.

Some other inline comments have also been moved to be on their own
lines.
This commit is contained in:
YashRE42 2022-01-05 06:56:13 +05:30 committed by Tim Abbott
parent bea41e975d
commit e17c96d86d
1 changed files with 6 additions and 8 deletions

View File

@ -793,17 +793,13 @@ export function show_flatpickr(element, callback, default_timestamp, options = {
disableMobile: true,
onKeyDown: (selectedDates, dateStr, instance, event) => {
if (is_numeric_key(event.key)) {
// Don't stopPropagation for numeric inputs, let them be handled normally
// Don't attempt to get_keydown_hotkey for numeric inputs
// as it would return undefined.
return;
}
const hotkey = get_keydown_hotkey(event);
if (hotkey === "backspace" || hotkey === "delete") {
// Don't stopPropagation for backspace or delete, let them be handled normally
return;
}
if (["tab", "shift_tab"].includes(hotkey.name)) {
const elems = [
instance.selectedDateElem,
@ -830,7 +826,8 @@ export function show_flatpickr(element, callback, default_timestamp, options = {
container.on("keydown", (e) => {
if (is_numeric_key(e.key)) {
return true; // Let users type numeric values
// Let users type numeric values
return true;
}
const hotkey = get_keydown_hotkey(e);
@ -840,7 +837,8 @@ export function show_flatpickr(element, callback, default_timestamp, options = {
}
if (hotkey.name === "backspace" || hotkey.name === "delete") {
return true; // Let backspace or delete be handled normally
// Let backspace or delete be handled normally
return true;
}
if (hotkey.name === "enter") {