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.

left_sidebar: Standardize DM list filter input.

Sayam Samal82edac01663e
diff --git a/web/src/click_handlers.ts b/web/src/click_handlers.ts
index 3dfb70ba4d0..193f4caabf6 100644
--- a/web/src/click_handlers.ts
+++ b/web/src/click_handlers.ts
@@ -880,7 +880,7 @@ export function initialize(): void {
window.location.hash = "narrow/is/dm";
});
- $("body").on("click", ".direct-messages-list-filter", (e) => {
+ $("body").on("click", ".direct-messages-search-section", (e) => {
// We don't want clicking on the filter to trigger the DM
// narrow defined on click for
// `#direct-messages-section-header.zoom-in`.
diff --git a/web/src/pm_list.ts b/web/src/pm_list.ts
index 695d6ac7ff6..84503ea78e0 100644
--- a/web/src/pm_list.ts
+++ b/web/src/pm_list.ts
@@ -227,20 +227,15 @@ function zoom_in(): void {
function zoom_out(): void {
zoomed = false;
- clear_search(true); // force rerender if the search is empty.
+ clear_search();
$(".direct-messages-container").removeClass("zoom-in").addClass("zoom-out");
$("#streams_list").show();
$(".left-sidebar .right-sidebar-items").show();
}
-export function clear_search(force_rerender = false): void {
+export function clear_search(): void {
const $filter = $(".direct-messages-list-filter").expectOne();
- if ($filter.val() !== "") {
- $filter.val("");
- update_private_messages();
- } else if (force_rerender) {
- update_private_messages();
- }
+ update_private_messages();
$filter.trigger("blur");
}
@@ -269,19 +264,11 @@ export function initialize(): void {
});
$(".direct-messages-container").on("input", ".direct-messages-list-filter", (e) => {
- e.stopPropagation();
e.preventDefault();
throttled_update_private_message();
});
- $(".direct-messages-container").on("click", "#clear-direct-messages-search-button", (e) => {
- e.stopPropagation();
- e.preventDefault();
-
- clear_search();
- });
-
$(".direct-messages-container").on("mouseenter", () => {
$("#direct-messages-section-header").addClass("hover-over-dm-section");
});
diff --git a/web/styles/left_sidebar.css b/web/styles/left_sidebar.css
index ea00230d686..d909d972fd4 100644
--- a/web/styles/left_sidebar.css
+++ b/web/styles/left_sidebar.css
@@ -1892,20 +1892,6 @@ li.topic-list-item {
}
}
-.direct-messages-search-section {
- .direct-messages-list-filter {
- grid-area: filter-box;
- padding-right: var(--line-height-sidebar-row-prominent);
- white-space: nowrap;
- text-overflow: ellipsis;
- overflow: hidden;
-
- &:placeholder-shown + #clear-direct-messages-search-button {
- visibility: hidden;
- }
- }
-}
-
.zero_count {
visibility: hidden;
}
diff --git a/web/templates/left_sidebar.hbs b/web/templates/left_sidebar.hbs
index cc2f7cac9cf..8d750992c62 100644
--- a/web/templates/left_sidebar.hbs
+++ b/web/templates/left_sidebar.hbs
@@ -182,12 +182,9 @@
<a class="zoom-out-hide" id="hide-more-direct-messages">
<span class="hide-more-direct-messages-text"> {{t 'back to channels' }}</span>
</a>
- <div class="zoom-out-hide direct-messages-search-section left-sidebar-filter-row">
- <input class="direct-messages-list-filter filter_text_input home-page-input" type="text" autocomplete="off" placeholder="{{t 'Filter direct messages' }}" />
- <button type="button" class="clear_search_button" id="clear-direct-messages-search-button">
- <i class="zulip-icon zulip-icon-close" aria-hidden="true"></i>
- </button>
- </div>
+ {{#> input input_type="filter-input" custom_classes="zoom-out-hide direct-messages-search-section" icon="search" input_button_icon="close"}}
+ <input type="text" class="input-element direct-messages-list-filter home-page-input" autocomplete="off" placeholder="{{t 'Filter direct messages' }}" />
+ {{/input}}
</div>
{{~!-- squash whitespace --~}}
<div id="left_sidebar_scroll_container" class="scrolling_list" data-simplebar data-simplebar-tab-index="-1">