Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
popovers: Add clear input button to stream search widget.
m-e-l-u-h-a-nee5aefee329c
diff --git a/static/js/user_profile.js b/static/js/user_profile.jsindex b43ccc27d01..d4b30d12592 100644--- a/static/js/user_profile.js+++ b/static/js/user_profile.js@@ -284,6 +284,17 @@ export function register_click_handlers() {handle_remove_stream_subscription(target_user_id, sub, removal_success, removal_failure);});+ $("body").on("click", "#user-profile-modal #clear_stream_search", (e) => {+ const input = $("#streams-tab .stream-search");+ input.val("");++ // This is a hack to rerender complete+ // stream list once the text is cleared.+ input.trigger("input");++ e.stopPropagation();+ e.preventDefault();+ });/* These click handlers are implemented as just deep links to the* relevant part of the Zulip UI, so we don't want preventDefault,* but we do want to close the modal when you click them. */@@ -294,4 +305,15 @@ export function register_click_handlers() {$("body").on("click", "#user-profile-modal .stream_list_item", () => {hide_user_profile();});++ $("body").on("input", "#streams-tab .stream-search", () => {+ const input = $("#streams-tab .stream-search");+ if (input.val().trim().length > 0) {+ $("#streams-tab #clear_stream_search").show();+ input.css("margin-right", "-20px");+ } else {+ $("#streams-tab #clear_stream_search").hide();+ input.css("margin-right", "0");+ }+ });}diff --git a/static/styles/popovers.css b/static/styles/popovers.cssindex 5a4749fff78..b1e8715bbbc 100644--- a/static/styles/popovers.css+++ b/static/styles/popovers.css@@ -381,6 +381,13 @@ ul {margin-left: auto;align-self: center;}++ #clear_stream_search {+ display: none;+ padding: 5px 8px 5px 4px;+ position: relative;+ right: 0;+ }}.subscription-group-list,@@ -545,6 +552,10 @@ ul {.stream-search {margin-bottom: 8px;}++ #clear_stream_search {+ padding-top: 1px;+ }}}}diff --git a/static/templates/user_profile_modal.hbs b/static/templates/user_profile_modal.hbsindex 42b496a3f06..035e929ecdf 100644--- a/static/templates/user_profile_modal.hbs+++ b/static/templates/user_profile_modal.hbs@@ -70,6 +70,9 @@<h3 class="stream-list-header">{{t 'Subscribed streams' }}</h3></div><input type="text" class="stream-search" placeholder="{{t 'Filter streams' }}" />+ <button type="button" class="clear_search_button" id="clear_stream_search">+ <i class="fa fa-remove" aria-hidden="true"></i>+ </button></div><div class="alert stream_list_info"></div><div class="subscription-stream-list">