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.

recent_view: Swap status-marker to vdots on hover or keyboard focus.

Alya Abbott2951db1fb193
diff --git a/web/src/recent_view_ui.ts b/web/src/recent_view_ui.ts
index 989246cc9c8..e1c4eb71f61 100644
--- a/web/src/recent_view_ui.ts
+++ b/web/src/recent_view_ui.ts
@@ -135,6 +135,73 @@ export function set_hide_other_views(callback: () => void): void {
hide_other_views_callback = callback;
}
+// Track the row's interaction state so we can swap the
+// `.visibility-status-icon` to a vdots glyph when the row is hovered,
+// keyboard-focused, or has the topic-actions popover open. We swap the
+// underlying icon-font class (rather than overlaying via mask-image)
+// so the rendered glyph matches every other vdots in the app exactly.
+const ORIGINAL_ICON_CLASS_DATA_ATTR = "data-vdots-original-icon-class";
+
+function swap_visibility_icon_to_vdots($icon: JQuery): void {
+ if ($icon.hasClass("recent-view-row-topic-menu")) {
+ return;
+ }
+ if ($icon.attr(ORIGINAL_ICON_CLASS_DATA_ATTR) !== undefined) {
+ return;
+ }
+ const icon_element = $icon.get(0);
+ if (icon_element === undefined) {
+ return;
+ }
+ const original_class = [...icon_element.classList].find(
+ (cls) => cls.startsWith("zulip-icon-") && cls !== "zulip-icon-more-vertical",
+ );
+ if (original_class === undefined) {
+ return;
+ }
+ $icon.attr(ORIGINAL_ICON_CLASS_DATA_ATTR, original_class);
+ $icon.removeClass(original_class).addClass("zulip-icon-more-vertical");
+}
+
+function restore_visibility_icon($icon: JQuery): void {
+ const original_class = $icon.attr(ORIGINAL_ICON_CLASS_DATA_ATTR);
+ if (original_class === undefined) {
+ return;
+ }
+ $icon.removeClass("zulip-icon-more-vertical").addClass(original_class);
+ $icon.removeAttr(ORIGINAL_ICON_CLASS_DATA_ATTR);
+}
+
+export function update_visibility_icon_swap_state($wrapper: JQuery): void {
+ const $icon = $wrapper.find(".visibility-status-icon");
+ if ($icon.length === 0) {
+ return;
+ }
+ const wrapper_element = $wrapper.get(0);
+ if (wrapper_element === undefined) {
+ return;
+ }
+ // Gate the focus-driven swap on the recent-view's own keyboard-
+ // visibility tracking rather than browser `:focus-visible`. The
+ // `no-visible-focus-outlines` class on `#recent_view` stays on
+ // until the first keyboard navigation key (see focus_outline_util),
+ // which means programmatic focus from view entry, sidebar clicks,
+ // or scroll-driven row re-focus shouldn't reveal the vdots glyph
+ // — the row has focus, but the user hasn't acted on the keyboard
+ // yet, so it would be a surprising reveal. Hover and popover-open
+ // remain unconditional.
+ const keyboard_focus_visible = !$("#recent_view").hasClass("no-visible-focus-outlines");
+ const should_swap =
+ $wrapper.hasClass("topic-popover-visible") ||
+ wrapper_element.matches(":hover") ||
+ (keyboard_focus_visible && wrapper_element.matches(":focus"));
+ if (should_swap) {
+ swap_visibility_icon_to_vdots($icon);
+ } else {
+ restore_visibility_icon($icon);
+ }
+}
+
export function set_initial_message_fetch_status(value: boolean): void {
is_initial_message_fetch_pending = value;
}
@@ -1971,6 +2038,19 @@ export function change_focused_element($elt: JQuery, input_key: string): boolean
input_key,
);
+ if (is_first_navigation) {
+ // The focus-driven vdots swap is gated on the same
+ // `no-visible-focus-outlines` flag we just cleared, so
+ // re-evaluate the currently-focused row's swap state now
+ // that keyboard focus has become "visible".
+ const $focused_wrapper = $(
+ "#recent-view-content-table .recent-view-topic-visibility:focus",
+ );
+ if ($focused_wrapper.length > 0) {
+ update_visibility_icon_swap_state($focused_wrapper);
+ }
+ }
+
if (is_first_navigation && is_table_focused()) {
// First navigation keypress after page load / view switch:
// just reveal the focus ring on the current row without
@@ -2398,6 +2478,14 @@ export function initialize({
focus_clicked_element(topic_row_index, COLUMNS.mute);
});
+ $("body").on(
+ "mouseenter mouseleave focusin focusout",
+ "#recent-view-content-table .recent-view-topic-visibility",
+ function (this: HTMLElement) {
+ update_visibility_icon_swap_state($(this));
+ },
+ );
+
// Search for all table rows (this combines stream & topic names)
$("body").on(
"input",
diff --git a/web/src/topic_popover.ts b/web/src/topic_popover.ts
index 74c9ee8f5f3..5f1d17b060e 100644
--- a/web/src/topic_popover.ts
+++ b/web/src/topic_popover.ts
@@ -13,6 +13,7 @@ import * as message_edit from "./message_edit.ts";
import * as message_summary from "./message_summary.ts";
import * as popover_menus from "./popover_menus.ts";
import * as popover_menus_data from "./popover_menus_data.ts";
+import * as recent_view_ui from "./recent_view_ui.ts";
import * as starred_messages_ui from "./starred_messages_ui.ts";
import {realm} from "./state_data.ts";
import * as stream_popover from "./stream_popover.ts";
@@ -119,6 +120,9 @@ export function initialize(): void {
);
if ($popover_trigger.length === 1) {
$popover_trigger.addClass("topic-popover-visible");
+ if ($popover_trigger.hasClass("recent-view-topic-visibility")) {
+ recent_view_ui.update_visibility_icon_swap_state($popover_trigger);
+ }
}
if (!stream_id) {
@@ -268,6 +272,9 @@ export function initialize(): void {
);
if ($popover_trigger.length === 1) {
$popover_trigger.removeClass("topic-popover-visible");
+ if ($popover_trigger.hasClass("recent-view-topic-visibility")) {
+ recent_view_ui.update_visibility_icon_swap_state($popover_trigger);
+ }
}
instance.destroy();
popover_menus.popover_instances.topics_menu = null;
diff --git a/web/styles/dark_theme.css b/web/styles/dark_theme.css
index 7eb341ebe5f..18d078fe9ac 100644
--- a/web/styles/dark_theme.css
+++ b/web/styles/dark_theme.css
@@ -104,12 +104,6 @@
}
}
- #recent_view
- .change_visibility_policy
- .visibility-status-icon:not(.recent-view-row-topic-menu):hover {
- filter: invert(1);
- }
-
#recent-view-content-table {
border-bottom-width: 1px;
}
diff --git a/web/styles/recent_view.css b/web/styles/recent_view.css
index 16baecda32b..cb5120f6099 100644
--- a/web/styles/recent_view.css
+++ b/web/styles/recent_view.css
@@ -84,20 +84,6 @@
> .change_visibility_policy {
display: flex;
-
- .visibility-status-icon:not(.recent-view-row-topic-menu):hover {
- /* Show vertical ellipsis when user hovers over visibility indicator icon. */
- background-image: url("../icons/more-vertical.svg");
- background-repeat: no-repeat;
- background-position: left bottom;
- background-size: contain;
- width: var(--base-font-size-px);
- height: var(--base-font-size-px);
-
- &::before {
- content: "";
- }
- }
}
> .change_visibility_policy .recent-view-row-topic-menu {