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.

custom_profile_fields: Open date picker calendar in both directions.

sandeepb4ba90e94428
diff --git a/web/src/custom_profile_fields_ui.ts b/web/src/custom_profile_fields_ui.ts
index b5097a990e7..70ae151f87f 100644
--- a/web/src/custom_profile_fields_ui.ts
+++ b/web/src/custom_profile_fields_ui.ts
@@ -329,7 +329,6 @@ export function initialize_custom_date_type_fields(
altInputClass: "date-field-alt-input " + common_class_name,
altFormat: "F j, Y",
allowInput: true,
- static: true,
// This helps us in accepting inputs in other formats
// like MM/DD/YYYY and basically any other format
// which is accepted by Date.
@@ -341,6 +340,17 @@ export function initialize_custom_date_type_fields(
// values.
formatDate: format_date,
allowInvalidPreload: true,
+ // Close the date picker on scroll, since flatpickr leaves the
+ // open calendar in place and it would drift away from the input.
+ onOpen(_selected_dates, _date_str, instance) {
+ window.addEventListener(
+ "scroll",
+ () => {
+ instance.close();
+ },
+ {capture: true, once: true},
+ );
+ },
onChange(_selected_dates, date_str, instance) {
update_date(instance, date_str);
if (date_str !== "Invalid Date") {
diff --git a/web/styles/settings.css b/web/styles/settings.css
index bee7f9519b6..47b5f4737dd 100644
--- a/web/styles/settings.css
+++ b/web/styles/settings.css
@@ -913,7 +913,7 @@ input[type="checkbox"] {
align-items: center;
width: var(--modal-input-width);
- .flatpickr-wrapper {
+ input.date-field-alt-input {
grid-column: datepicker-start / close-button-end;
grid-row: close-button;
}