Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

flatpickr: Fix tab navigation when time is disabled.

Shubham Padia81a079de09f1
diff --git a/web/src/flatpickr.ts b/web/src/flatpickr.ts
index 403f2b7a7b7..a4000a93ebe 100644
--- a/web/src/flatpickr.ts
+++ b/web/src/flatpickr.ts
@@ -18,6 +18,8 @@ function is_numeric_key(key: string): boolean {
return ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"].includes(key);
}
+const ENABLE_TIME_DEFAULT = true;
+
export function show_flatpickr(
element: HTMLElement,
callback: (time: string) => void,
@@ -26,9 +28,9 @@ export function show_flatpickr(
): flatpickr.Instance {
const $flatpickr_input = $<HTMLInputElement>("<input>").attr("id", "#timestamp_flatpickr");
+ options.enableTime = options.enableTime ?? ENABLE_TIME_DEFAULT;
flatpickr_instance = flatpickr(util.the($flatpickr_input), {
mode: "single",
- enableTime: true,
clickOpens: false,
defaultDate: default_timestamp,
plugins: [
@@ -58,11 +60,14 @@ export function show_flatpickr(
// navigate between the elements in flatpickr itself
// and the confirmation button at the bottom of the
// popover.
- const elems = [
- instance.selectedDateElem,
+ const enabled_time_options = [
instance.hourElement,
instance.minuteElement,
...(user_settings.twenty_four_hour_time ? [] : [instance.amPM]),
+ ];
+ const elems = [
+ instance.selectedDateElem,
+ ...(options.enableTime ? enabled_time_options : []),
$(".flatpickr-confirm")[0],
];
assert(event.target instanceof HTMLElement);