Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
left_sidebar: Improve logic to detect empty filter input with pills.
Sayam Samal434145356864
diff --git a/web/src/topic_list.ts b/web/src/topic_list.tsindex b9b3e9509c7..8e5ee2db444 100644--- a/web/src/topic_list.ts+++ b/web/src/topic_list.ts@@ -506,21 +506,6 @@ const filter_options = new Map<string, string>([[$t({defaultMessage: "All topics"}), ""],]);-export function update_clear_button(): void {- const $filter_query = $("#topic_filter_query");- const $clear_button = $(".filter-topics .input-button");- if (get_left_sidebar_topic_search_term() === "" && get_typeahead_search_term() === "") {- $clear_button.css("visibility", "hidden");- // When we use backspace to clear the content of the search box,- // a <br> tag is left inside it, preventing the data-placeholder- // value from reappearing as the element never becomes truly empty.- // Therefore, we manually set the text to empty.- $filter_query.empty();- } else {- $clear_button.css("visibility", "visible");- }-}-export function setup_topic_search_typeahead(): void {const $input = $("#topic_filter_query");const $pill_container = $("#left-sidebar-filter-topic-input");@@ -592,7 +577,6 @@ export function setup_topic_search_typeahead(): void {});search_pill_widget.onPillRemove(() => {- update_clear_button();const stream_id = active_stream_id();if (stream_id !== undefined) {const widget = active_widgets.get(stream_id);@@ -639,8 +623,5 @@ export function initialize({const stream_id = active_stream_id();assert(stream_id !== undefined);active_widgets.get(stream_id)?.build();- update_clear_button();});-- update_clear_button();}diff --git a/web/styles/inputs.css b/web/styles/inputs.cssindex b1ba4ba468f..b0e83b2bde2 100644--- a/web/styles/inputs.css+++ b/web/styles/inputs.css@@ -114,23 +114,42 @@padding: 0.25em; /* 4px at 16px/1em */}-/* We use the `input` tag in the selector to avoid conflicts- with the pill containing counterpart, which uses a `contenteditable`- div instead of an input element, and thus doesn't support the- placeholder pseudo-classes. */-.filter-input input.input-element {- &:placeholder-shown {- /* In case of filter inputs, when the input field- is empty, we hide the input button and adjust- the right padding to compensate for the same. */- padding-right: 0.5em;-- ~ .input-button {- visibility: hidden;+.filter-input {+ /* We use the `input` tag in the selector to avoid conflicts+ with the pill containing counterpart, which uses a `contenteditable`+ div instead of an input element, and thus doesn't support the+ placeholder pseudo-classes. */+ input.input-element {+ &:placeholder-shown {+ /* In case of filter inputs, when the input field+ is empty, we hide the input button and adjust+ the right padding to compensate for the same. */+ padding-right: 0.5em;++ ~ .input-button {+ visibility: hidden;+ }+ }++ &:not(:placeholder-shown) {+ @extend .input-active-styles;}}- &:not(:placeholder-shown) {- @extend .input-active-styles;+ /* Specific styles for filter input with pills */+ &.has-input-pills {+ &:not(:has(.pill)):has(.input:empty) {+ .input-element {+ padding-right: 0.5em;+ }++ .input-button {+ visibility: hidden;+ }+ }++ &:has(.pill):not(:has(.input:empty)) .input-element {+ @extend .input-active-styles;+ }}}