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: Fix date field cross icon visibility

sandeep729ce42ffa8a
diff --git a/web/src/custom_profile_fields_ui.ts b/web/src/custom_profile_fields_ui.ts
index 73538fbbaf5..b5097a990e7 100644
--- a/web/src/custom_profile_fields_ui.ts
+++ b/web/src/custom_profile_fields_ui.ts
@@ -286,6 +286,9 @@ export function initialize_custom_date_type_fields(
);
const original_value = people.get_custom_profile_data(user_id, field_id)?.value ?? "";
instance.setDate(original_value);
+ $input_elem
+ .closest(".custom_user_field")
+ .toggleClass("has-date", original_value !== "");
if (!for_profile_settings_panel) {
// Trigger "input" event so that save button state can
// be toggled in "Manage user" modal.
@@ -340,6 +343,11 @@ export function initialize_custom_date_type_fields(
allowInvalidPreload: true,
onChange(_selected_dates, date_str, instance) {
update_date(instance, date_str);
+ if (date_str !== "Invalid Date") {
+ $(instance.element)
+ .closest(".custom_user_field")
+ .toggleClass("has-date", date_str !== "");
+ }
},
});
@@ -382,8 +390,23 @@ export function initialize_custom_date_type_fields(
const $displayed_input = $(this).parent().find(".date-field-alt-input");
$displayed_input.val("");
$custom_user_field.val("");
+ $(this).closest(".custom_user_field").removeClass("has-date");
$custom_user_field.trigger("input");
});
+
+ $(element_id)
+ .find<HTMLInputElement>("input.date-field-alt-input")
+ .on("input", function () {
+ const has_value = $(this).val()!.length > 0;
+ $(this).closest(".custom_user_field").toggleClass("has-date", has_value);
+ });
+
+ $(element_id)
+ .find<HTMLInputElement>(".custom_user_field .custom_user_field_value.datepicker")
+ .each(function () {
+ const has_value = $(this).val()!.length > 0;
+ $(this).closest(".custom_user_field").toggleClass("has-date", has_value);
+ });
}
export function initialize_custom_pronouns_type_fields(element_id: string): void {
diff --git a/web/styles/settings.css b/web/styles/settings.css
index 1ba52558885..bee7f9519b6 100644
--- a/web/styles/settings.css
+++ b/web/styles/settings.css
@@ -1729,7 +1729,7 @@ label.preferences-radio-choice-label {
resize: vertical;
}
- &:hover .remove_date {
+ &.has-date:hover .remove_date {
display: inline-flex;
}