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: Floor channel column to fit the "Channel" header.

Aman Agrawal6efb62abea5e
diff --git a/web/src/recent_view_ui.ts b/web/src/recent_view_ui.ts
index 30569e0135f..dfeaa0bb895 100644
--- a/web/src/recent_view_ui.ts
+++ b/web/src/recent_view_ui.ts
@@ -1695,6 +1695,27 @@ function set_time_column_width_css_variable(): void {
$(":root").css("--recent-view-time-text-width", `${Math.ceil(max_width)}px`);
}
+function set_channel_header_min_width_css_variable(): void {
+ if (page_params.is_node_test) {
+ return;
+ }
+ const $channel_sort_header = $(".recent-view-channel-sort-header");
+ if ($channel_sort_header.length === 0) {
+ return;
+ }
+ // Measure the "Channel" sort header's intrinsic width by cloning
+ // it into a hidden max-content wrapper inside the header cell (so
+ // it keeps the same styles). CSS floors the channel column to this
+ // width so the label never overlaps the "Conversation" header.
+ const measure_wrapper = util.make_offscreen_measurement_container();
+ measure_wrapper.append($channel_sort_header[0]!.cloneNode(true));
+ const $header_cell = $channel_sort_header.closest("th");
+ $header_cell[0]!.append(measure_wrapper);
+ const width = measure_wrapper.getBoundingClientRect().width;
+ measure_wrapper.remove();
+ $(":root").css("--recent-view-header-channel-column-min-width", `${Math.ceil(width)}px`);
+}
+
export function update_participants_column_class(): void {
if (!page_params.is_node_test) {
max_avatars = Number.parseInt($(":root").css("--recent-view-max-avatars"), 10);
@@ -1739,6 +1760,9 @@ export function complete_rerender(coming_from_other_views = false): void {
});
$("#recent_view_table").html(rendered_body);
+ // Measure the "Channel" header now that it is in the DOM.
+ set_channel_header_min_width_css_variable();
+
// `show_selected_filters` needs to be called after the Recent
// Conversations view has been added to the DOM, to ensure that filters
// have the correct classes (checked or not) if Recent Conversations
diff --git a/web/styles/recent_view.css b/web/styles/recent_view.css
index 93a6ed36271..7328e36f257 100644
--- a/web/styles/recent_view.css
+++ b/web/styles/recent_view.css
@@ -664,26 +664,35 @@
spans align with channel and topic text in rows. Sort
arrows are inside the spans, so 3 columns suffice.
1em = 16px at 16px/1em, matching the 1em (16px
- at 16px/1em) privacy icon width in data rows. */
+ at 16px/1em) privacy icon width in data rows.
+
+ The first column is floored to the "Channel" header's
+ JS-measured width so the label never overlaps the next
+ column when channel names are short or absent. */
display: grid;
grid-template-columns:
- calc(
- min(
- calc(
- var(--longest-subscribed-channel-name-width) +
- 1em + 8px
- ),
- calc(
+ max(
+ var(--recent-view-header-channel-column-min-width, 0px),
+ calc(
+ min(
calc(
- 100% -
- var(
- --recent-view-header-channel-column-adjustment
- )
- ) /
- 3
- )
- ) +
- var(--recent-view-header-channel-column-adjustment)
+ var(
+ --longest-subscribed-channel-name-width
+ ) +
+ 1em + 8px
+ ),
+ calc(
+ calc(
+ 100% -
+ var(
+ --recent-view-header-channel-column-adjustment
+ )
+ ) /
+ 3
+ )
+ ) +
+ var(--recent-view-header-channel-column-adjustment)
+ )
)
auto 1fr auto;
align-items: stretch;
@@ -799,13 +808,24 @@
". . conversation-name .";
width: 100%;
/* We add 1em for the privacy icon and 8px for the flexbox
- gap between the icon and the channel name. */
+ gap between the icon and the channel name. Floored to
+ match the header grid's "Channel" floor. */
grid-template-columns:
- min(
+ max(
calc(
- var(--longest-subscribed-channel-name-width) + 1em + 8px
+ var(
+ --recent-view-header-channel-column-min-width,
+ 0px
+ ) -
+ var(--recent-view-header-channel-column-adjustment)
),
- calc(100% / 3)
+ min(
+ calc(
+ var(--longest-subscribed-channel-name-width) + 1em +
+ 8px
+ ),
+ calc(100% / 3)
+ )
)
auto 1fr auto;
align-items: center;