Daily use 8: Context menu widget: max-content width, hints, disabled rows, clickable submenu triggers (#492) #542

Closed
charles wants to merge 0 commits from dailyuse-8-context-menu-widget into dailyuse
Owner

What was built

widgets::context_menu (spec §3.2, §8; ContextMenu.module.css:18-43,56-200,351-369, ContextMenu.tsx:66-68,378-620):

  • Width = max-content: the card is as wide as its widest row (label, or hint up to 20 rem, + the grid gap + icon / caret / checkbox + the row's padding and 1 px border, + the card's padding and border), clamped to [13rem, min(21.5rem, window - 1.5rem)]. card_width(&items) is public; MIN_WIDTH = 208, MAX_WIDTH = 344; WIDTH is kept (= MIN_WIDTH) for message_actions' placement. Submenus follow the same rule.
  • Labels never wrap: single line, cut with an ellipsis past the room they have (measured with inline_flow::measure_text; iced 0.14 has no text-overflow).
  • Item::Action { label, on_press, danger, hint: Option<String>, disabled: bool, icon: Option<IconName> }: the hint is a .75rem/1rem --text-tertiary-muted line under the label (.itemHint, wraps at min(20 rem, row)); the icon sits at the row's end (.itemIcon, grid column 2); a disabled row is --interactive-muted at 50 %, never hovered, emits nothing.
  • Item::Submenu { label, items, on_press: Option<Message> }: hovering opens the submenu; with on_press, a click on the row sends it (onTriggerSelect: the mute rows) and a click on the caret still opens/closes it (data-submenu-caret); without it, a click toggles as before.
  • Placement: 4 px under the cursor, flipped above when it does not fit; the submenu 10 px past its row's edge (to the left when it does not fit), its top on the row's top; both kept 12 px inside the window (floating-ui flip + shift).
  • Parity details now matched: the card's 1 px border is inside its size (box-sizing: border-box) and rows keep their transparent 1 px border, so menus are 2 px taller and wider; the submenu caret is 14 px in --text-tertiary.
  • Every caller (message_actions/menu.rs, threads/menu.rs, participant_menu.rs, stream_menu.rs, call/pip.rs, dms/notes.rs, composer/plus_menu.rs, screenshare/mod.rs, forum/mod.rs) sets the new fields to the old behaviour (hint: None, disabled: false, icon: None, on_press: None).

How it was tested

  • crates/fluxer-ui/tests/context_menu.rs (headless, tiny-skia): width_fits_widest_label, width_clamped_min_13rem_max_21_5rem (incl. a 200 px window), long_label_ellipsised_not_wrapped, submenu_trigger_click_emits (row click acts, hover opens, caret toggles), disabled_row_emits_nothing, hint_row_height (47 px), edge_padding_12. Written first and seen failing, then passing.
  • New goldens context_menu_long_labels, context_menu_hint_row (+ docs/screenshots/context-menu-*.png, README table rows). Redrawn: control_bar_sharing, message_context_menu, participant_menu, participant_menu_entrance_submenu, stream_menu, stream_menu_audio_settings, stream_menu_audio_sources (#443: "Audio sources: Entire system" now on one line), stream_settings_menu. All rendered on lavapipe in the fluxer-native-shots:u2204 image; the full screenshot suite (122) passes there. No threshold changed.
  • cargo xtask ci green on the host (this machine has no lavapipe, so the screenshot step ran in the Ubuntu 22.04 lavapipe container as above; the whole xtask ci could not run in that container because webrtc-sys fails to build there, an environment issue). No FLUXER_DESKTOP_TESTS tests apply.

Deviations from the plan

  • The reference images in docs/screenshots/ are the lavapipe goldens; no Electron side-by-side was captured (no live client here).
  • The hint is drawn under the label (the plan allows "under or after"; the original's MenuItem puts it under).
  • Collision handling: the fork's node_modules (base-ui) are not checked out, so its exact collisionAvoidance default could not be read; I used flip on the side axis + shift on the align axis (floating-ui's usual). Worth a look if a menu near the right edge should open leftwards of the cursor instead of being shifted.

Closes #492
Closes #367
Closes #443
Refs #129

🤖 Generated with Claude Code

## What was built `widgets::context_menu` (spec §3.2, §8; `ContextMenu.module.css:18-43,56-200,351-369`, `ContextMenu.tsx:66-68,378-620`): - **Width = max-content**: the card is as wide as its widest row (label, or hint up to 20 rem, + the grid gap + icon / caret / checkbox + the row's padding and 1 px border, + the card's padding and border), clamped to `[13rem, min(21.5rem, window - 1.5rem)]`. `card_width(&items)` is public; `MIN_WIDTH` = 208, `MAX_WIDTH` = 344; `WIDTH` is kept (= `MIN_WIDTH`) for `message_actions`' placement. Submenus follow the same rule. - **Labels never wrap**: single line, cut with an ellipsis past the room they have (measured with `inline_flow::measure_text`; iced 0.14 has no text-overflow). - `Item::Action { label, on_press, danger, hint: Option<String>, disabled: bool, icon: Option<IconName> }`: the hint is a `.75rem`/`1rem` `--text-tertiary-muted` line under the label (`.itemHint`, wraps at min(20 rem, row)); the icon sits at the row's end (`.itemIcon`, grid column 2); a disabled row is `--interactive-muted` at 50 %, never hovered, emits nothing. - `Item::Submenu { label, items, on_press: Option<Message> }`: hovering opens the submenu; with `on_press`, a click on the row sends it (`onTriggerSelect`: the mute rows) and a click on the caret still opens/closes it (`data-submenu-caret`); without it, a click toggles as before. - **Placement**: 4 px under the cursor, flipped above when it does not fit; the submenu 10 px past its *row's* edge (to the left when it does not fit), its top on the row's top; both kept 12 px inside the window (floating-ui flip + shift). - Parity details now matched: the card's 1 px border is inside its size (`box-sizing: border-box`) and rows keep their transparent 1 px border, so menus are 2 px taller and wider; the submenu caret is 14 px in `--text-tertiary`. - Every caller (`message_actions/menu.rs`, `threads/menu.rs`, `participant_menu.rs`, `stream_menu.rs`, `call/pip.rs`, `dms/notes.rs`, `composer/plus_menu.rs`, `screenshare/mod.rs`, `forum/mod.rs`) sets the new fields to the old behaviour (`hint: None, disabled: false, icon: None`, `on_press: None`). ## How it was tested - `crates/fluxer-ui/tests/context_menu.rs` (headless, tiny-skia): `width_fits_widest_label`, `width_clamped_min_13rem_max_21_5rem` (incl. a 200 px window), `long_label_ellipsised_not_wrapped`, `submenu_trigger_click_emits` (row click acts, hover opens, caret toggles), `disabled_row_emits_nothing`, `hint_row_height` (47 px), `edge_padding_12`. Written first and seen failing, then passing. - New goldens `context_menu_long_labels`, `context_menu_hint_row` (+ `docs/screenshots/context-menu-*.png`, README table rows). Redrawn: `control_bar_sharing`, `message_context_menu`, `participant_menu`, `participant_menu_entrance_submenu`, `stream_menu`, `stream_menu_audio_settings`, `stream_menu_audio_sources` (#443: "Audio sources: Entire system" now on one line), `stream_settings_menu`. All rendered on lavapipe in the `fluxer-native-shots:u2204` image; the full screenshot suite (122) passes there. No threshold changed. - `cargo xtask ci` green on the host (this machine has no lavapipe, so the screenshot step ran in the Ubuntu 22.04 lavapipe container as above; the whole `xtask ci` could not run in that container because `webrtc-sys` fails to build there, an environment issue). No `FLUXER_DESKTOP_TESTS` tests apply. ## Deviations from the plan - The reference images in `docs/screenshots/` are the lavapipe goldens; no Electron side-by-side was captured (no live client here). - The hint is drawn under the label (the plan allows "under or after"; the original's `MenuItem` puts it under). - Collision handling: the fork's `node_modules` (base-ui) are not checked out, so its exact `collisionAvoidance` default could not be read; I used flip on the side axis + shift on the align axis (floating-ui's usual). Worth a look if a menu near the right edge should open leftwards of the cursor instead of being shifted. Closes #492 Closes #367 Closes #443 Refs #129 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The context menu card is now as wide as its widest row (`width:
max-content`) between 13 rem and 21.5 rem, and never wider than the
window less 1.5 rem (ContextMenu.module.css:18-43, submenus :351-369).
Labels stay on one line and end in an ellipsis past the maximum. Action
rows gain a hint under the label (.itemHint, .75rem), an icon at the
row's end and a disabled look (.item.disabled); submenu rows gain
`on_press`, sent by a click on the row while hovering still opens the
submenu (onTriggerSelect, ContextMenu.tsx:478-560). The menu opens 4 px
under the cursor, flips above it when it does not fit, a submenu opens
10 px past its row and both stay 12 px inside the window
(ContextMenu.tsx:66-68). The card's 1 px border now sits inside its size
as `box-sizing: border-box` has it, and the rows keep their transparent
1 px border, so menus are 2 px taller than before.

Every caller sets the new fields to their old behaviour.

Refs #492

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Two new goldens, context_menu_long_labels (a card as wide as its
widest label, "Audio sources: Entire system" on one line, an
ellipsised label, the "Mute channel" submenu open 10 px past its row)
and context_menu_hint_row (a hint row, a disabled row, an icon row, a
danger row), with their reference images. The eight existing menu
goldens redrawn for the content-sized cards, the 1 px borders and the
4 px cursor offset: control_bar_sharing, message_context_menu,
participant_menu, participant_menu_entrance_submenu, stream_menu,
stream_menu_audio_settings, stream_menu_audio_sources (#443: the row is
on one line now), stream_settings_menu. Rendered on lavapipe in the
fluxer-native-shots:u2204 (Ubuntu 22.04) image, like the Linux runner.

Refs #492

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Refs #492

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Author
Owner

Independent review: Daily use 8 (context menu widget)

Scope: git diff f2de7cd..origin/dailyuse-8-context-menu-widget (fc4f34c).

Local gate: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in the review worktree returned green (exit 0). The host has a Vulkan adapter, so the screenshot suite really ran: 122/122 goldens pass, including context_menu_long_labels, context_menu_hint_row and the 8 redrawn menu goldens. tests/context_menu.rs: 7/7 pass.

Checks

  1. Plan tests: all 7 named tests are present (width_fits_widest_label, width_clamped_min_13rem_max_21_5rem, long_label_ellipsised_not_wrapped, submenu_trigger_click_emits, disabled_row_emits_nothing, hint_row_height, edge_padding_12). They assert the spec's values: 208/344 px, window − 24 px, 4/10/12 px, a 47 px hint row and the caret/checkbox/icon end columns. Both goldens are present, and the stream menu golden now draws the #443 row on one line.
  2. Interfaces: Item::Action { label, on_press, danger, hint: Option<String>, disabled: bool, icon: Option<IconName> } and Item::Submenu { label, items, on_press: Option<Message> } match the plan exactly. MIN_WIDTH, MAX_WIDTH, EDGE_PADDING, CURSOR_OFFSET, SUBMENU_OFFSET and card_width are public. All callers in the Files list only set the new fields to their old defaults.
  3. Invariants: the change is UI-only with no new I/O path, no new dependencies, no fixtures and no secrets. File ownership stays within the Task 8 list plus registration and README files.
  4. Parity, checked against the fork: ContextMenu.tsx:66-68 (12 / 4 / 10) matches. ContextMenu.module.css matches: .contextMenu min/max width, max-content, padding .375rem, 1px border inside the box, .item padding plus 1px transparent border, gap .5rem, .itemHint .75rem/1rem/margin .0625rem/max 20rem/overflow-wrap: anywhere, .submenuCaret .875rem in --text-tertiary, and .item.disabled in --interactive-muted at 0.5 opacity. SubMenu onTriggerSelect also matches (ContextMenu.tsx:478-560): a label click acts, a caret click falls through to the trigger's toggle, hovering opens.
  5. Review Focus: no item belongs to Task 8 (item 4 covers menu contents, which are Tasks 17 and 18).

Findings

  • minor (parity, follow-up suggested): main menu collision handling differs from base-ui. The fork has no node_modules, but the upstream checkout has @base-ui/react@1.5.0 (the fork pins 1.8.0, which I could not check). In 1.5.0 the context-menu root uses DROPDOWN_COLLISION_AVOIDANCE with shiftCrossAxis = true (MenuPositioner.js:113), so flip({ mainAxis: false, crossAxis: 'alignment' }) applies, followed by a shift on both axes (useAnchorPositioning.js:151-180).

    • Vertically, the menu does not flip above the cursor; it is shifted up to stay 12 px inside the window.
    • Horizontally, it flips alignment: its right edge goes to the cursor before any shift.
    • The widget does the opposite on both axes (place() flips vertically and only shifts horizontally).
    • Submenus (POPUP_COLLISION_AVOIDANCE) flip sides as implemented, but they also flip alignment vertically (bottom aligned to the row) where the widget only shifts.

    The spec does not pin this down, so it does not block. Suggestion: confirm against 1.8.0 and open a follow-up issue (the edge_padding_12 corner assertions would change).

  • minor: message_actions/mod.rs:352 still places the "More" menu with the fixed context_menu::WIDTH (208). A message menu wider than 13 rem (for example a long translated label) would overlap the button. Menus anchored to a button rather than the cursor (More, plus menu, stream and PiP) also now gain the 4 px cursor offset. This is visible only in already-redrawn goldens and is harmless today.

  • minor: when the window is narrower than the card, labels are clipped instead of ending in an ellipsis. ellipsize runs with the unclamped card_width, and the window clamp only happens later in Anchored::layout. This only happens in windows under about 230 px.

  • minor (note only): Item::Submenu has no hint, disabled or danger, though the fork's SubMenu supports all three. This is not in the plan's interface. Tasks 29 and 31 should know about it in case a mute parent row ever needs them.

The commit trailers use the repo CLAUDE.md attribution line and Refs #492, and the PR body has the right Closes/Refs lines.

Verdict: approve. No blocking findings and local CI is green, screenshots included.

## Independent review: Daily use 8 (context menu widget) Scope: `git diff f2de7cd..origin/dailyuse-8-context-menu-widget` (fc4f34c). **Local gate:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in the review worktree returned **green (exit 0)**. The host has a Vulkan adapter, so the screenshot suite really ran: **122/122 goldens pass**, including `context_menu_long_labels`, `context_menu_hint_row` and the 8 redrawn menu goldens. `tests/context_menu.rs`: 7/7 pass. ### Checks 1. **Plan tests:** all 7 named tests are present (`width_fits_widest_label`, `width_clamped_min_13rem_max_21_5rem`, `long_label_ellipsised_not_wrapped`, `submenu_trigger_click_emits`, `disabled_row_emits_nothing`, `hint_row_height`, `edge_padding_12`). They assert the spec's values: 208/344 px, window − 24 px, 4/10/12 px, a 47 px hint row and the caret/checkbox/icon end columns. Both goldens are present, and the stream menu golden now draws the #443 row on one line. 2. **Interfaces:** `Item::Action { label, on_press, danger, hint: Option<String>, disabled: bool, icon: Option<IconName> }` and `Item::Submenu { label, items, on_press: Option<Message> }` match the plan exactly. `MIN_WIDTH`, `MAX_WIDTH`, `EDGE_PADDING`, `CURSOR_OFFSET`, `SUBMENU_OFFSET` and `card_width` are public. All callers in the Files list only set the new fields to their old defaults. 3. **Invariants:** the change is UI-only with no new I/O path, no new dependencies, no fixtures and no secrets. File ownership stays within the Task 8 list plus registration and README files. 4. **Parity, checked against the fork:** `ContextMenu.tsx:66-68` (12 / 4 / 10) matches. `ContextMenu.module.css` matches: `.contextMenu` min/max width, `max-content`, padding .375rem, 1px border inside the box, `.item` padding plus 1px transparent border, gap .5rem, `.itemHint` .75rem/1rem/margin .0625rem/max 20rem/`overflow-wrap: anywhere`, `.submenuCaret` .875rem in `--text-tertiary`, and `.item.disabled` in `--interactive-muted` at 0.5 opacity. `SubMenu` `onTriggerSelect` also matches (`ContextMenu.tsx:478-560`): a label click acts, a caret click falls through to the trigger's toggle, hovering opens. 5. **Review Focus:** no item belongs to Task 8 (item 4 covers menu contents, which are Tasks 17 and 18). ### Findings - **minor (parity, follow-up suggested): main menu collision handling differs from base-ui.** The fork has no node_modules, but the upstream checkout has `@base-ui/react@1.5.0` (the fork pins 1.8.0, which I could not check). In 1.5.0 the context-menu root uses `DROPDOWN_COLLISION_AVOIDANCE` with `shiftCrossAxis = true` (`MenuPositioner.js:113`), so `flip({ mainAxis: false, crossAxis: 'alignment' })` applies, followed by a shift on both axes (`useAnchorPositioning.js:151-180`). - Vertically, the menu does **not** flip above the cursor; it is shifted up to stay 12 px inside the window. - Horizontally, it **flips alignment**: its right edge goes to the cursor before any shift. - The widget does the opposite on both axes (`place()` flips vertically and only shifts horizontally). - Submenus (`POPUP_COLLISION_AVOIDANCE`) flip sides as implemented, but they also flip alignment vertically (bottom aligned to the row) where the widget only shifts. The spec does not pin this down, so it does not block. Suggestion: confirm against 1.8.0 and open a `follow-up` issue (the `edge_padding_12` corner assertions would change). - **minor: `message_actions/mod.rs:352` still places the "More" menu with the fixed `context_menu::WIDTH` (208).** A message menu wider than 13 rem (for example a long translated label) would overlap the button. Menus anchored to a button rather than the cursor (More, plus menu, stream and PiP) also now gain the 4 px cursor offset. This is visible only in already-redrawn goldens and is harmless today. - **minor: when the window is narrower than the card, labels are clipped instead of ending in an ellipsis.** `ellipsize` runs with the unclamped `card_width`, and the window clamp only happens later in `Anchored::layout`. This only happens in windows under about 230 px. - **minor (note only): `Item::Submenu` has no `hint`, `disabled` or `danger`, though the fork's `SubMenu` supports all three.** This is not in the plan's interface. Tasks 29 and 31 should know about it in case a mute parent row ever needs them. The commit trailers use the repo CLAUDE.md attribution line and `Refs #492`, and the PR body has the right Closes/Refs lines. **Verdict: approve.** No blocking findings and local CI is green, screenshots included.
Author
Owner

Merged into dailyuse at 863726f (combined merge of the first twelve Daily use tasks).

Merged into `dailyuse` at 863726f (combined merge of the first twelve Daily use tasks).
charles closed this pull request 2026-11-14 13:04:04 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.