Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-row-menu-hint-wrap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor: the row menu's consequence hints ("merges #15118 into v5 now via hive's identity, attributed to you", "records your approval; the hive's merge sweep merges #15118 on its next pass…") no longer run past the menu border over the rows behind it — a menu with hints grows wider (capped to the viewport) and each hint wraps on its own line under its label, the rescan hint included (#15175).
13 changes: 10 additions & 3 deletions src/pkg/dashboard/stage_tracker_row_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func stageTrackerRowActionsPreamble(t *testing.T, html string) string {
jsFunc(t, html, "stageTrackerFlatActions"),
jsFunc(t, html, "stageTrackerSelectionActions"),
jsFunc(t, html, "stageTrackerMenuItemHtml"),
jsFunc(t, html, "stageTrackerMenuHasHints"),
jsFunc(t, html, "stageTrackerMenuHtml"),
jsFunc(t, html, "stageTrackerMenuPosition"),
jsFunc(t, html, "stageTrackerSelBarHtml"),
Expand Down Expand Up @@ -285,7 +286,7 @@ assert.strictEqual(by.open.enabled, true);

// Menu markup.
const menu = stageTrackerMenuHtml(as, 'o/r#1 · Parked');
assert.ok(menu.startsWith('<div class="ham-menu" role="menu"'));
assert.ok(menu.startsWith('<div class="ham-menu ham-menu-hinted" role="menu"'), 'the rescan hint makes it a hinted menu: ' + menu.slice(0, 60));
assert.ok(menu.includes('<div class="ham-menu-head">o/r#1 · Parked</div>'));
assert.strictEqual((menu.match(/role="menuitem"/g) || []).length, 11, 'six top-level items + five decide options');
assert.ok(menu.includes('data-ham-act="hold" tabindex="-1" aria-disabled="true" title="' + STAGE_TRACKER_WHY_WRITE + '"'), 'disabled items carry the reason');
Expand Down Expand Up @@ -620,7 +621,7 @@ const one = { ...issue, linked_prs: [issue.linked_prs[1]] };
assert.strictEqual(stageTrackerDecisionTarget(one).number, 15020, 'one parked PR: the issue row decides it, as before');
assert.ok(!ids(stageTrackerRowActions(one, ctx)).includes('decide:delegate-all'));
const menu = stageTrackerMenuHtml(stageTrackerRowActions(issue, ctx), 'x');
assert.ok(menu.includes('data-ham-act="decide:delegate-all"') && menu.includes('Let hive decide — all 2 PRs<span class="ham-menu-more">per PR</span>'));
assert.ok(menu.includes('data-ham-act="decide:delegate-all"') && menu.includes('Let hive decide — all 2 PRs<span class="ham-menu-hint">per PR</span>'));

// The selection model runs over sub-rows: keys in document order, painted
// on the sub nodes; a sub-row click selects the PR, not its parent.
Expand Down Expand Up @@ -1086,7 +1087,13 @@ const at = s => menu.indexOf(s);
assert.ok(at('data-ham-act="decide:merge-now"') > 0 && at('data-ham-act="decide:merge-now"') < at('data-ham-act="decide:queue-merge"'));
assert.ok(at('data-ham-act="decide:queue-merge"') < at('data-ham-act="decide"'), 'merge answers above Decide…');
assert.ok(at('data-ham-act="decide"') < at('data-ham-act="hold"') && at('data-ham-act="hold"') < at('data-ham-act="open"'), 'generic items last');
assert.ok(menu.includes('<span class="ham-menu-more">merges #317 into main now via hive&#39;s identity, attributed to you</span>') || menu.includes('<span class="ham-menu-more">merges #317 into main now via hive\'s identity, attributed to you</span>'), 'consequence line rendered: ' + menu);
assert.ok(menu.includes('<span class="ham-menu-hint">merges #317 into main now via hive&#39;s identity, attributed to you</span>') || menu.includes('<span class="ham-menu-hint">merges #317 into main now via hive\'s identity, attributed to you</span>'), 'consequence line rendered: ' + menu);
// Hints stack under their label and the menu grows for them (#15175).
assert.ok(menu.startsWith('<div class="ham-menu ham-menu-hinted"'), 'a menu with hints is ham-menu-hinted: ' + menu.slice(0, 80));
assert.ok(/class="ham-menu-item ham-menu-item-hinted" data-ham-act="decide:merge-now"/.test(menu), 'the hinted item stacks label over hint: ' + menu);
assert.ok(!/class="ham-menu-item[^"]*ham-menu-item-hinted"[^>]*data-ham-act="open"/.test(menu), 'items without a hint keep the inline layout');
assert.ok(!stageTrackerMenuHtml([{ id: 'open', label: 'Open', enabled: true }], 'x').includes('ham-menu-hinted'), 'no hints: plain menu width');
assert.ok(stageTrackerMenuHasHints([{ id: 'decide', label: 'Decide…', enabled: true, submenu: [{ id: 'x', label: 'x', hint: 'per PR' }] }]), 'a submenu hint counts');

// A writer without the merger role sees the merge answers, greyed with the
// role reason — never silently missing.
Expand Down
20 changes: 17 additions & 3 deletions src/pkg/dashboard/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,13 @@
.ham-menu-item[aria-disabled="true"]:hover { background: transparent; }
.ham-menu-item.ham-menu-danger { color: var(--red); }
.ham-menu-item .ham-menu-more { color: var(--text-faint); }
/* A menu whose items carry a consequence hint ("merges #N into v5 now
via hive's identity…") grows wider and stacks label over hint; the
hint wraps, so no hint length can run past the menu border
(see the fixed-row-menu-hint-wrap changelog fragment). */
.ham-menu.ham-menu-hinted { max-width: min(45em, calc(100vw - 2 * var(--sp-3))); }
.ham-menu-item.ham-menu-item-hinted { flex-direction: column; align-items: flex-start; gap: var(--sp-1); white-space: normal; }
.ham-menu-item .ham-menu-hint { display: block; color: var(--text-faint); font-size: var(--fs-xs); white-space: normal; overflow-wrap: anywhere; }
.ham-submenu { display: none; margin: 0 0 0 var(--sp-3); padding-left: var(--sp-2); border-left: var(--line-width) solid var(--line-subtle); }
.ham-menu-item[aria-expanded="true"] + .ham-submenu { display: block; }
/* tracker-cues: the Activity Monitor's shared cue vocabulary (owner,
Expand Down Expand Up @@ -17327,12 +17334,19 @@ <h2 class="config-title" id="activity-monitor-labels-title">All labels</h2>
if (a.submenu) {
return `${a.sep ? '<div class="ham-menu-sep" role="separator"></div>' : ''}<button type="button" role="menuitem" class="ham-menu-item" data-ham-act="${esc(a.id)}" aria-haspopup="menu" aria-expanded="false" tabindex="-1"${dis}>${esc(a.label)}<span class="ham-menu-more" aria-hidden="true">▸</span></button><div class="ham-submenu" role="menu" aria-label="${esc(a.label)}">${a.submenu.map(stageTrackerMenuItemHtml).join('')}</div>`;
}
return `${a.sep ? '<div class="ham-menu-sep" role="separator"></div>' : ''}<button type="button" role="menuitem" class="ham-menu-item${a.danger ? ' ham-menu-danger' : ''}" data-ham-act="${esc(a.id)}" tabindex="-1"${dis}>${esc(a.label)}${a.hint ? `<span class="ham-menu-more">${esc(a.hint)}</span>` : ''}</button>`;
// A hint stacks under the label (ham-menu-item-hinted) and wraps, so
// the consequence line never overflows the menu (#15165).
return `${a.sep ? '<div class="ham-menu-sep" role="separator"></div>' : ''}<button type="button" role="menuitem" class="ham-menu-item${a.danger ? ' ham-menu-danger' : ''}${a.hint ? ' ham-menu-item-hinted' : ''}" data-ham-act="${esc(a.id)}" tabindex="-1"${dis}>${esc(a.label)}${a.hint ? `<span class="ham-menu-hint">${esc(a.hint)}</span>` : ''}</button>`;
}
// Pure: true when any action (or submenu action) carries a hint.
function stageTrackerMenuHasHints(actions) {
return (actions || []).some(a => !!a.hint || (a.submenu && stageTrackerMenuHasHints(a.submenu)));
}
// Pure: the menu markup (roles menu / menuitem, the Decide group as a
// nested menu toggled by its item).
// nested menu toggled by its item). A menu with hints is ham-menu-hinted
// (wider, hints stacked and wrapping).
function stageTrackerMenuHtml(actions, head) {
return `<div class="ham-menu" role="menu" aria-label="Row actions" tabindex="-1">${head ? `<div class="ham-menu-head">${esc(head)}</div>` : ''}${actions.map(stageTrackerMenuItemHtml).join('')}</div>`;
return `<div class="ham-menu${stageTrackerMenuHasHints(actions) ? ' ham-menu-hinted' : ''}" role="menu" aria-label="Row actions" tabindex="-1">${head ? `<div class="ham-menu-head">${esc(head)}</div>` : ''}${actions.map(stageTrackerMenuItemHtml).join('')}</div>`;
}
// Pure: place the menu at the pointer, flipped/clamped to stay on screen.
function stageTrackerMenuPosition(x, y, w, h, vw, vh) {
Expand Down
29 changes: 29 additions & 0 deletions src/pkg/dashboard/webstatic/static_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,3 +724,32 @@ func TestStaticCostStaleRecordingNoticeWiring(t *testing.T) {
}
}
}

// TestStaticRowMenuHintWraps: the Activity Monitor row menu's consequence
// hints ("merges #15118 into v5 now via hive's identity, attributed to
// you") ran ~1150px past the menu border because the item was a nowrap
// flex row with the hint inline after the label. A menu with hints is
// wider (ham-menu-hinted), and each hint stacks under its label and wraps,
// so no hint length can overflow (hivecommons/hive#15175).
func TestStaticRowMenuHintWraps(t *testing.T) {
body, err := os.ReadFile("../static/index.html")
if err != nil {
t.Fatal(err)
}
html := string(body)
for _, want := range []string{
`.ham-menu.ham-menu-hinted { max-width: min(45em, calc(100vw - 2 * var(--sp-3))); }`,
`.ham-menu-item.ham-menu-item-hinted { flex-direction: column; align-items: flex-start; gap: var(--sp-1); white-space: normal; }`,
`.ham-menu-item .ham-menu-hint { display: block; color: var(--text-faint); font-size: var(--fs-xs); white-space: normal; overflow-wrap: anywhere; }`,
`${a.hint ? ' ham-menu-item-hinted' : ''}`,
"${a.hint ? `<span class=\"ham-menu-hint\">${esc(a.hint)}</span>` : ''}",
`<div class="ham-menu${stageTrackerMenuHasHints(actions) ? ' ham-menu-hinted' : ''}"`,
} {
if !strings.Contains(html, want) {
t.Errorf("index.html missing row-menu hint wrap wiring %q", want)
}
}
if strings.Contains(html, `<span class="ham-menu-more">${esc(a.hint)}</span>`) {
t.Error("a text hint must not reuse .ham-menu-more (the nowrap ▸ submenu affordance)")
}
}
Loading