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.

inbox: Focus currently selected option in dropdown.

Aman Agrawal69d59acc5a5c
diff --git a/web/src/dropdown_widget.js b/web/src/dropdown_widget.js
index 77d38b38e77..8aa0436c19a 100644
--- a/web/src/dropdown_widget.js
+++ b/web/src/dropdown_widget.js
@@ -22,6 +22,8 @@ export const DATA_TYPES = {
export class DropdownWidget {
constructor({
widget_name,
+ // You can bold the selected `option` by setting `option.bold_current_selection` to `true`.
+ // Currently, not implemented for stream names.
get_options,
item_click_callback,
// Provide an parent element to widget which will be re-rendered if the widget is setup again.
diff --git a/web/src/inbox_ui.js b/web/src/inbox_ui.js
index 7b00521000d..9a1d49145ff 100644
--- a/web/src/inbox_ui.js
+++ b/web/src/inbox_ui.js
@@ -36,6 +36,7 @@ let dms_dict = new Map();
let topics_dict = new Map();
let streams_dict = new Map();
let update_triggered_by_user = false;
+let filters_dropdown_widget;
const FILTERS = {
ALL_TOPICS: "all_topics",
@@ -507,14 +508,23 @@ function filters_dropdown_options() {
{
unique_id: FILTERS.ALL_TOPICS,
name: $t({defaultMessage: "All topics"}),
+ bold_current_selection:
+ filters_dropdown_widget &&
+ filters_dropdown_widget.current_value === FILTERS.ALL_TOPICS,
},
{
unique_id: FILTERS.UNMUTED_TOPICS,
name: $t({defaultMessage: "Unmuted topics"}),
+ bold_current_selection:
+ filters_dropdown_widget &&
+ filters_dropdown_widget.current_value === FILTERS.UNMUTED_TOPICS,
},
{
unique_id: FILTERS.FOLLOWED_TOPICS,
name: $t({defaultMessage: "Followed topics"}),
+ bold_current_selection:
+ filters_dropdown_widget &&
+ filters_dropdown_widget.current_value === FILTERS.FOLLOWED_TOPICS,
},
];
}
@@ -559,7 +569,7 @@ export function complete_rerender() {
revive_current_focus();
}, 0);
- new dropdown_widget.DropdownWidget({
+ filters_dropdown_widget = new dropdown_widget.DropdownWidget({
widget_name: "inbox-filter",
get_options: filters_dropdown_options,
item_click_callback: filter_click_handler,
@@ -571,7 +581,9 @@ export function complete_rerender() {
unique_id_type: dropdown_widget.DATA_TYPES.STRING,
default_id: filters.values().next().value,
hide_search_box: true,
- }).setup();
+ bold_current_selection: true,
+ });
+ filters_dropdown_widget.setup();
}
export function search_and_update() {
diff --git a/web/styles/zulip.css b/web/styles/zulip.css
index e82c5b322d0..42974bc57bc 100644
--- a/web/styles/zulip.css
+++ b/web/styles/zulip.css
@@ -3465,6 +3465,10 @@ select.invite-as {
}
}
+.dropdown-list-item-common-styles .dropdown-list-bold-selected {
+ font-weight: 700;
+}
+
#scheduled_messages_overlay .error-icon-message-recipient {
width: 15px;
height: 100%;
diff --git a/web/templates/dropdown_list.hbs b/web/templates/dropdown_list.hbs
index f58561b9689..ac0ae2cae0a 100644
--- a/web/templates/dropdown_list.hbs
+++ b/web/templates/dropdown_list.hbs
@@ -8,7 +8,11 @@
{{else if is_setting_disabled}}
<span class="setting-disabled-option"><i class="fa fa-ban" aria-hidden="true"></i>{{t "Disable" }}</span>
{{else}}
- {{name}}
+ {{#if bold_current_selection}}
+ <span class="dropdown-list-bold-selected">{{name}}</span>
+ {{else}}
+ {{name}}
+ {{/if}}
{{/if}}
</a>
</li>