diff --git a/.github/scripts/integration-governance.cjs b/.github/scripts/integration-governance.cjs index 932e3e362d..2210a5684e 100644 --- a/.github/scripts/integration-governance.cjs +++ b/.github/scripts/integration-governance.cjs @@ -9,7 +9,7 @@ const MAX_COMMITS = 1000; const MAX_AUTHOR_BATCH = 50; // This literal is inside the enrolled .github closure. A caller-supplied // preparedBy.sourceSHA must never choose a new executable verifier tree. -const TRUSTED_SCRIPTS_TREE = 'c6b5ba0094fcd1304b391315b196b44f4cc77633'; +const TRUSTED_SCRIPTS_TREE = '6067449abe5556e11068e2901a222a45c03fe1d2'; const SOURCE = 'https://github.com/kubernetes-sigs/kubebuilder-release-tools/tree/012269a88fa4c034a0acf1ba84c26b195c0dbab4'; const sha = value => crypto.createHash('sha256').update(value).digest('hex'); const git = (args, cwd = process.cwd()) => diff --git a/changelog.d/added-activity-monitor-phone-tap-targets.md b/changelog.d/added-activity-monitor-phone-tap-targets.md new file mode 100644 index 0000000000..46c7e284f9 --- /dev/null +++ b/changelog.d/added-activity-monitor-phone-tap-targets.md @@ -0,0 +1 @@ +- Activity monitor on a phone: every control meets the 44px coarse-pointer floor (`--tap-target-touch`), the per-row select / β‹― controls move from the hidden left gutter into the row header, and the β‹― menu opens as a full-screen sheet with tap-sized items. diff --git a/src/docs/dashboard-design-system.md b/src/docs/dashboard-design-system.md index 7c19bf13c4..daca06a0a2 100644 --- a/src/docs/dashboard-design-system.md +++ b/src/docs/dashboard-design-system.md @@ -326,6 +326,22 @@ the focus trap and the body scroll lock behave as on desktop; desktop layout is unchanged apart from the affordance. Metrics come from the `--modal-scroll-*` / `--modal-sheet-*` tokens in `tokens.css`. +### Phone tap targets: `--tap-target-touch` + +`--tap-target` (40px) sizes icon-only controls on desktop and the 768px tier. +Phone tiers that must meet the Apple HIG / WCAG 2.5.5 coarse-pointer floor +remap it for their subtree to `--tap-target-touch` (44px, `base.css`) rather +than hard-coding sizes: the activity monitor does this in the +`.modal-sheet` phone query, so its chips, selects, search box, Merged / +queue chips, label chips, ⧉ β›Ά πŸ“Ί header tools, grip, ?, βš™ and the per-row +select / β‹― controls all grow together. The row controls leave the +hover-revealed left gutter for the top-right corner of the row header and +the β‹― menu opens as a `.hive-dialog.modal-sheet` (`stageTrackerOpenSheet`, +`tracker-actions.js`) with tap-sized items. Inline text links (issue / PR +refs, prose anchors) are the one documented exclusion. The gate is +`webstatic/testdata/tracker-phone-ergonomics.js`, run by +`dashboard-mobile-shots.mjs` at 390Γ—844. + ## Ratchet plan `pkg/dashboard/webstatic/style_ratchet_test.go`, modeled on diff --git a/src/pkg/dashboard/static-src/css/base.css b/src/pkg/dashboard/static-src/css/base.css index ab696b47f1..b12cbd4c57 100644 --- a/src/pkg/dashboard/static-src/css/base.css +++ b/src/pkg/dashboard/static-src/css/base.css @@ -39,6 +39,9 @@ into a circle several times its glyph. */ --tap-target: 40px; --tap-glyph: 16px; + /* Coarse-pointer floor (Apple HIG / WCAG 2.5.5: 44pt). Phone tiers + that must meet it remap --tap-target to this for their subtree. */ + --tap-target-touch: 44px; --tap-ring: 28px; /* Terminal surface β€” terminals always read as terminals: near-black in dark mode, deep neutral (never white) in light mode. The diff --git a/src/pkg/dashboard/static-src/css/tracker.css b/src/pkg/dashboard/static-src/css/tracker.css index 2262f2922b..d636004b9b 100644 --- a/src/pkg/dashboard/static-src/css/tracker.css +++ b/src/pkg/dashboard/static-src/css/tracker.css @@ -1065,3 +1065,40 @@ .sts-sample { padding: var(--sp-3) var(--sp-2) 0; } .sts-sample .ham-row { padding: var(--sp-2); } .sts-sample .ham-cols { padding-top: 0; } + /* Phone ergonomics (#17163, part of #17158): in the .modal-sheet tier + (the query responsive.css uses for full-screen dialogs) every control + in the activity monitor meets the coarse-pointer floor. --tap-target is + remapped to --tap-target-touch for this section only, so the grip, ?, + βš™ and the ⧉ β›Ά πŸ“Ί header tools (responsive.css sizes them from the same + token) grow with the chips, selects, search box, Merged / queue chips + and label chips. The select checkbox and β‹― kebab leave the left gutter + (12px wide on touch, hover-revealed on desktop) for the top-right + corner of the row header, always visible and tap-sized; the header + reserves their width so the title wraps beside them. The kebab menu + itself is a .hive-dialog.modal-sheet (tracker-actions.js adds + .ham-menu-sheet) with tap-sized items and the sheet's safe-area pad. + Desktop (and the popout, kiosk, TV / display modes at desktop widths) + does not match the query and is unchanged. Tokens only (ADR-0018). */ + @media (max-width: 640px), ((pointer: coarse) and (max-width: 820px)) { + #activity-monitor-section { --tap-target: var(--tap-target-touch); } + #activity-monitor-section .ham-toolbar .ham-chip, #activity-monitor-section .ham-labels .ham-chip, #activity-monitor-section .ham-selbar .ham-chip, #activity-monitor-section .ham-compact .ham-chip, + #activity-monitor-section .ham-select, #activity-monitor-section .ham-input, + #activity-monitor-section .ham-merged-count, #activity-monitor-section .ham-queue-chip, + #activity-monitor-section .ham-repo-chip, #activity-monitor-section .cue-event-ico, #activity-monitor-section .ham-lead-act, #activity-monitor-section .ham-badge-mod[data-action] { + box-sizing: border-box; min-height: var(--tap-target); min-width: var(--tap-target); + } + #activity-monitor-section .ham-toolbar .ham-chip, #activity-monitor-section .ham-labels .ham-chip, #activity-monitor-section .ham-selbar .ham-chip, #activity-monitor-section .ham-repo-chip, #activity-monitor-section .ham-lead-act { padding-top: var(--sp-2); padding-bottom: var(--sp-2); } + #activity-monitor-section .ham-select, #activity-monitor-section .ham-input { height: var(--tap-target); padding-top: 0; padding-bottom: 0; } + #activity-monitor-section .ham-repo-filter { min-height: var(--tap-target); align-items: center; } + #activity-monitor-section .ham-header-tool { width: var(--tap-target); min-width: var(--tap-target); height: var(--tap-target); min-height: var(--tap-target); padding: 0; font-size: var(--tap-glyph); } + #activity-monitor-panel { padding-left: 0; } + #activity-monitor-section .ham-row > .ham-row-tools, #activity-monitor-section .ham-sub > .ham-row-tools { left: auto; right: 0; top: 0; width: auto; flex-direction: row; align-items: flex-start; gap: var(--sp-2); z-index: 1; } + #activity-monitor-section .ham-row > .ham-row-head, #activity-monitor-section .ham-sub > .ham-row-head { padding-right: calc(2 * var(--tap-target) + var(--sp-2) + var(--sp-3)); min-height: var(--tap-target); } + #activity-monitor-section .ham-sel, #activity-monitor-section .ham-kebab { width: var(--tap-target); height: var(--tap-target); min-width: var(--tap-target); min-height: var(--tap-target); font-size: var(--tap-glyph); opacity: 1; } + .ham-menu.ham-menu-sheet { position: static; min-width: 0; max-width: none; padding: 0; border: 0; box-shadow: none; background: transparent; font-size: var(--fs-touch); } + .ham-menu-sheet .ham-menu-head { display: none; } + .ham-menu-sheet .ham-menu-item { min-height: var(--tap-target-touch); padding: var(--sp-3) var(--sp-4); white-space: normal; overflow-wrap: anywhere; } + .ham-menu-sheet .ham-menu-hint, .ham-menu-sheet .ham-menu-note { font-size: var(--fs-sm); } + .ham-menu-sheet .ham-menu-sep { margin: var(--sp-2) 0; } + .ham-sheet .ham-sheet-body { padding-bottom: var(--safe-area-bottom); } + } diff --git a/src/pkg/dashboard/static-src/js/tracker-actions.js b/src/pkg/dashboard/static-src/js/tracker-actions.js index 512ed3ef50..0c75743eb8 100644 --- a/src/pkg/dashboard/static-src/js/tracker-actions.js +++ b/src/pkg/dashboard/static-src/js/tracker-actions.js @@ -807,9 +807,32 @@ document.removeEventListener('keydown', m.onKey, true); window.removeEventListener('resize', m.onAway); window.removeEventListener('scroll', m.onAway, true); - if (m.el.parentNode) m.el.parentNode.removeChild(m.el); + const host = m.host || m.el; + if (host.hiveDialogClose) host.hiveDialogClose(); else if (host.parentNode) host.parentNode.removeChild(host); if (refocus && m.restore && typeof m.restore.focus === 'function' && document.contains(m.restore)) m.restore.focus(); } + // The phone tier of the dashboard's .modal-sheet (responsive.css): on a + // phone the row menu and the Merged / queue popovers open as full-screen + // sheets instead of anchored popovers. One query, shared with the CSS. + const STAGE_TRACKER_SHEET_QUERY = '(max-width: 640px), ((pointer: coarse) and (max-width: 820px))'; + function stageTrackerIsPhoneSheet() { + return typeof window !== 'undefined' && typeof window.matchMedia === 'function' && !!window.matchMedia(STAGE_TRACKER_SHEET_QUERY).matches; + } + // Wrap `body` in a .hive-dialog.modal-sheet overlay (Esc / βœ• / backdrop + // close via hiveWireDialog; safe-area pad from the shared sheet CSS) and + // return the overlay. `onClose` runs once, however the sheet was closed; + // `onEnter` runs for Enter on a focused control inside the body. + function stageTrackerOpenSheet(title, body, cls, onClose, onEnter) { + const overlay = document.createElement('div'); + overlay.className = 'hive-dialog-overlay'; + if (typeof hiveRememberModalOpen === 'function') hiveRememberModalOpen(overlay); + const id = 'ham-sheet-' + Math.random().toString(36).slice(2); + overlay.innerHTML = ``; + overlay.querySelector('.ham-sheet-body').appendChild(body); + document.body.appendChild(overlay); + hiveWireDialog(overlay, () => { if (typeof onClose === 'function') onClose(); }, null, null, null, () => { if (typeof onEnter === 'function') onEnter(); }); + return overlay; + } // Open the menu for `items` at (x, y) β€” or below `anchor` β€” and run the // picked action on them. // Pure: does the menu (or one of its submenus) offer an enabled Let hive decide. @@ -825,13 +848,26 @@ const tpl = document.createElement('template'); tpl.innerHTML = stageTrackerMenuHtml(actions, head); const el = tpl.content.firstElementChild; - document.body.appendChild(el); - let x = at.x, y = at.y; - if (at.anchor && typeof at.anchor.getBoundingClientRect === 'function') { const r = at.anchor.getBoundingClientRect(); x = r.left; y = r.bottom; } - const pos = stageTrackerMenuPosition(x, y, el.offsetWidth, el.offsetHeight, window.innerWidth, window.innerHeight); - el.style.setProperty('left', pos.left + 'px'); - el.style.setProperty('top', pos.top + 'px'); + // On a phone the menu is a full-screen sheet (#17163): the fixed + // popover's ~30px items are too small to tap and it can land under + // the thumb. Same markup, roles and keyboard model; the sheet adds βœ•, + // backdrop and Esc via the shared dialog wiring. + const sheet = stageTrackerIsPhoneSheet(); const m = { el, items, restore: at.restore || at.anchor || null }; + if (sheet) { + el.classList.add('ham-menu-sheet'); + m.host = stageTrackerOpenSheet(head, el, 'ham-menu-dialog', () => stageTrackerCloseMenu(true), () => { + const b = document.activeElement && document.activeElement.closest ? document.activeElement.closest('[role="menuitem"]') : null; + if (b && el.contains(b)) b.click(); + }); + } else { + document.body.appendChild(el); + let x = at.x, y = at.y; + if (at.anchor && typeof at.anchor.getBoundingClientRect === 'function') { const r = at.anchor.getBoundingClientRect(); x = r.left; y = r.bottom; } + const pos = stageTrackerMenuPosition(x, y, el.offsetWidth, el.offsetHeight, window.innerWidth, window.innerHeight); + el.style.setProperty('left', pos.left + 'px'); + el.style.setProperty('top', pos.top + 'px'); + } m.onAway = e => { if (e.type !== 'pointerdown' || !el.contains(e.target)) stageTrackerCloseMenu(false); }; m.onKey = e => { if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); stageTrackerCloseMenu(true); return; } @@ -844,7 +880,7 @@ case 'End': e.preventDefault(); stageTrackerMenuFocus(el, 'last'); break; case 'ArrowRight': if (b && b.getAttribute('aria-haspopup') === 'menu' && b.getAttribute('aria-disabled') !== 'true') { e.preventDefault(); b.setAttribute('aria-expanded', 'true'); stageTrackerMenuFocus(el, 1, b); } break; case 'ArrowLeft': { const sub = b && b.closest('.ham-submenu'); if (sub && sub.previousElementSibling) { e.preventDefault(); sub.previousElementSibling.setAttribute('aria-expanded', 'false'); sub.previousElementSibling.focus(); } break; } - case 'Tab': stageTrackerCloseMenu(true); break; + case 'Tab': if (!sheet) stageTrackerCloseMenu(true); break; } }; el.addEventListener('click', e => { @@ -861,10 +897,12 @@ stageTrackerCloseMenu(true); stageTrackerDoAction(m.items, act); }); - document.addEventListener('pointerdown', m.onAway, true); + if (!sheet) { + document.addEventListener('pointerdown', m.onAway, true); + window.addEventListener('resize', m.onAway); + window.addEventListener('scroll', m.onAway, true); + } document.addEventListener('keydown', m.onKey, true); - window.addEventListener('resize', m.onAway); - window.addEventListener('scroll', m.onAway, true); _stageTrackerMenu = m; stageTrackerSetMenuOpen(document.getElementById('activity-monitor-panel'), true); if (at.expandDecide) { const d = el.querySelector('[data-ham-act="decide"]'); if (d && d.getAttribute('aria-disabled') !== 'true') d.setAttribute('aria-expanded', 'true'); } diff --git a/src/pkg/dashboard/static-src/js/tracker-merged.js b/src/pkg/dashboard/static-src/js/tracker-merged.js index 55a3b498bb..369d830837 100644 --- a/src/pkg/dashboard/static-src/js/tracker-merged.js +++ b/src/pkg/dashboard/static-src/js/tracker-merged.js @@ -902,10 +902,13 @@ } function stageTrackerTerminalView(d, nowMs) { if (!d || !Array.isArray(d.items)) return d; + // Merge state is null until its first fetch lands; a row menu can be + // opened before then, so read it as "nothing merged yet". + const merged = _stageTrackerMergeState || {}; const items = d.items.map(item => { const rowKey = stageTrackerItemKey(item), pin = _stageTrackerCelebrating[rowKey]; const active = pin && pin.until > nowMs; - if (item.kind === 'pr' && _stageTrackerMergeState[rowKey] === true) { + if (item.kind === 'pr' && merged[rowKey] === true) { const fact = _stageTrackerTerminalFacts[rowKey]; return (fact && fact.until > nowMs) || Number(item.stage) >= STAGE_TRACKER_TERMINAL ? stageTrackerTerminalItem(item, rowKey) : null; } @@ -919,7 +922,7 @@ } const linked = source.map(lp => { const key = stageTrackerItemKey(stageTrackerLinkedPRItem(item, lp)); - if (_stageTrackerMergeState[key] !== true) return lp; + if (merged[key] !== true) return lp; const fact = _stageTrackerTerminalFacts[key]; return (fact && fact.until > nowMs) || Number(lp.stage) >= STAGE_TRACKER_TERMINAL ? stageTrackerTerminalItem(lp, key) : null; }).filter(Boolean); diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 2bd02df612..4a05095213 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -55,6 +55,9 @@ into a circle several times its glyph. */ --tap-target: 40px; --tap-glyph: 16px; + /* Coarse-pointer floor (Apple HIG / WCAG 2.5.5: 44pt). Phone tiers + that must meet it remap --tap-target to this for their subtree. */ + --tap-target-touch: 44px; --tap-ring: 28px; /* Terminal surface β€” terminals always read as terminals: near-black in dark mode, deep neutral (never white) in light mode. The @@ -2405,6 +2408,43 @@ .sts-sample { padding: var(--sp-3) var(--sp-2) 0; } .sts-sample .ham-row { padding: var(--sp-2); } .sts-sample .ham-cols { padding-top: 0; } + /* Phone ergonomics (#17163, part of #17158): in the .modal-sheet tier + (the query responsive.css uses for full-screen dialogs) every control + in the activity monitor meets the coarse-pointer floor. --tap-target is + remapped to --tap-target-touch for this section only, so the grip, ?, + βš™ and the ⧉ β›Ά πŸ“Ί header tools (responsive.css sizes them from the same + token) grow with the chips, selects, search box, Merged / queue chips + and label chips. The select checkbox and β‹― kebab leave the left gutter + (12px wide on touch, hover-revealed on desktop) for the top-right + corner of the row header, always visible and tap-sized; the header + reserves their width so the title wraps beside them. The kebab menu + itself is a .hive-dialog.modal-sheet (tracker-actions.js adds + .ham-menu-sheet) with tap-sized items and the sheet's safe-area pad. + Desktop (and the popout, kiosk, TV / display modes at desktop widths) + does not match the query and is unchanged. Tokens only (ADR-0018). */ + @media (max-width: 640px), ((pointer: coarse) and (max-width: 820px)) { + #activity-monitor-section { --tap-target: var(--tap-target-touch); } + #activity-monitor-section .ham-toolbar .ham-chip, #activity-monitor-section .ham-labels .ham-chip, #activity-monitor-section .ham-selbar .ham-chip, #activity-monitor-section .ham-compact .ham-chip, + #activity-monitor-section .ham-select, #activity-monitor-section .ham-input, + #activity-monitor-section .ham-merged-count, #activity-monitor-section .ham-queue-chip, + #activity-monitor-section .ham-repo-chip, #activity-monitor-section .cue-event-ico, #activity-monitor-section .ham-lead-act, #activity-monitor-section .ham-badge-mod[data-action] { + box-sizing: border-box; min-height: var(--tap-target); min-width: var(--tap-target); + } + #activity-monitor-section .ham-toolbar .ham-chip, #activity-monitor-section .ham-labels .ham-chip, #activity-monitor-section .ham-selbar .ham-chip, #activity-monitor-section .ham-repo-chip, #activity-monitor-section .ham-lead-act { padding-top: var(--sp-2); padding-bottom: var(--sp-2); } + #activity-monitor-section .ham-select, #activity-monitor-section .ham-input { height: var(--tap-target); padding-top: 0; padding-bottom: 0; } + #activity-monitor-section .ham-repo-filter { min-height: var(--tap-target); align-items: center; } + #activity-monitor-section .ham-header-tool { width: var(--tap-target); min-width: var(--tap-target); height: var(--tap-target); min-height: var(--tap-target); padding: 0; font-size: var(--tap-glyph); } + #activity-monitor-panel { padding-left: 0; } + #activity-monitor-section .ham-row > .ham-row-tools, #activity-monitor-section .ham-sub > .ham-row-tools { left: auto; right: 0; top: 0; width: auto; flex-direction: row; align-items: flex-start; gap: var(--sp-2); z-index: 1; } + #activity-monitor-section .ham-row > .ham-row-head, #activity-monitor-section .ham-sub > .ham-row-head { padding-right: calc(2 * var(--tap-target) + var(--sp-2) + var(--sp-3)); min-height: var(--tap-target); } + #activity-monitor-section .ham-sel, #activity-monitor-section .ham-kebab { width: var(--tap-target); height: var(--tap-target); min-width: var(--tap-target); min-height: var(--tap-target); font-size: var(--tap-glyph); opacity: 1; } + .ham-menu.ham-menu-sheet { position: static; min-width: 0; max-width: none; padding: 0; border: 0; box-shadow: none; background: transparent; font-size: var(--fs-touch); } + .ham-menu-sheet .ham-menu-head { display: none; } + .ham-menu-sheet .ham-menu-item { min-height: var(--tap-target-touch); padding: var(--sp-3) var(--sp-4); white-space: normal; overflow-wrap: anywhere; } + .ham-menu-sheet .ham-menu-hint, .ham-menu-sheet .ham-menu-note { font-size: var(--fs-sm); } + .ham-menu-sheet .ham-menu-sep { margin: var(--sp-2) 0; } + .ham-sheet .ham-sheet-body { padding-bottom: var(--safe-area-bottom); } + } .nq-rail { margin: var(--sp-5) 0; padding: var(--sp-5); border: 1px solid var(--border-color); border-radius: var(--r); overflow-wrap: anywhere; } .nq-rail h3, .nq-rail h4, .nq-rail h5 { margin: var(--sp-4) 0; } .nq-muted { color: var(--text-secondary); font-size: var(--fs-sm); } @@ -23437,9 +23477,32 @@

All labels

document.removeEventListener('keydown', m.onKey, true); window.removeEventListener('resize', m.onAway); window.removeEventListener('scroll', m.onAway, true); - if (m.el.parentNode) m.el.parentNode.removeChild(m.el); + const host = m.host || m.el; + if (host.hiveDialogClose) host.hiveDialogClose(); else if (host.parentNode) host.parentNode.removeChild(host); if (refocus && m.restore && typeof m.restore.focus === 'function' && document.contains(m.restore)) m.restore.focus(); } + // The phone tier of the dashboard's .modal-sheet (responsive.css): on a + // phone the row menu and the Merged / queue popovers open as full-screen + // sheets instead of anchored popovers. One query, shared with the CSS. + const STAGE_TRACKER_SHEET_QUERY = '(max-width: 640px), ((pointer: coarse) and (max-width: 820px))'; + function stageTrackerIsPhoneSheet() { + return typeof window !== 'undefined' && typeof window.matchMedia === 'function' && !!window.matchMedia(STAGE_TRACKER_SHEET_QUERY).matches; + } + // Wrap `body` in a .hive-dialog.modal-sheet overlay (Esc / βœ• / backdrop + // close via hiveWireDialog; safe-area pad from the shared sheet CSS) and + // return the overlay. `onClose` runs once, however the sheet was closed; + // `onEnter` runs for Enter on a focused control inside the body. + function stageTrackerOpenSheet(title, body, cls, onClose, onEnter) { + const overlay = document.createElement('div'); + overlay.className = 'hive-dialog-overlay'; + if (typeof hiveRememberModalOpen === 'function') hiveRememberModalOpen(overlay); + const id = 'ham-sheet-' + Math.random().toString(36).slice(2); + overlay.innerHTML = ``; + overlay.querySelector('.ham-sheet-body').appendChild(body); + document.body.appendChild(overlay); + hiveWireDialog(overlay, () => { if (typeof onClose === 'function') onClose(); }, null, null, null, () => { if (typeof onEnter === 'function') onEnter(); }); + return overlay; + } // Open the menu for `items` at (x, y) β€” or below `anchor` β€” and run the // picked action on them. // Pure: does the menu (or one of its submenus) offer an enabled Let hive decide. @@ -23455,13 +23518,26 @@

All labels

const tpl = document.createElement('template'); tpl.innerHTML = stageTrackerMenuHtml(actions, head); const el = tpl.content.firstElementChild; - document.body.appendChild(el); - let x = at.x, y = at.y; - if (at.anchor && typeof at.anchor.getBoundingClientRect === 'function') { const r = at.anchor.getBoundingClientRect(); x = r.left; y = r.bottom; } - const pos = stageTrackerMenuPosition(x, y, el.offsetWidth, el.offsetHeight, window.innerWidth, window.innerHeight); - el.style.setProperty('left', pos.left + 'px'); - el.style.setProperty('top', pos.top + 'px'); + // On a phone the menu is a full-screen sheet (#17163): the fixed + // popover's ~30px items are too small to tap and it can land under + // the thumb. Same markup, roles and keyboard model; the sheet adds βœ•, + // backdrop and Esc via the shared dialog wiring. + const sheet = stageTrackerIsPhoneSheet(); const m = { el, items, restore: at.restore || at.anchor || null }; + if (sheet) { + el.classList.add('ham-menu-sheet'); + m.host = stageTrackerOpenSheet(head, el, 'ham-menu-dialog', () => stageTrackerCloseMenu(true), () => { + const b = document.activeElement && document.activeElement.closest ? document.activeElement.closest('[role="menuitem"]') : null; + if (b && el.contains(b)) b.click(); + }); + } else { + document.body.appendChild(el); + let x = at.x, y = at.y; + if (at.anchor && typeof at.anchor.getBoundingClientRect === 'function') { const r = at.anchor.getBoundingClientRect(); x = r.left; y = r.bottom; } + const pos = stageTrackerMenuPosition(x, y, el.offsetWidth, el.offsetHeight, window.innerWidth, window.innerHeight); + el.style.setProperty('left', pos.left + 'px'); + el.style.setProperty('top', pos.top + 'px'); + } m.onAway = e => { if (e.type !== 'pointerdown' || !el.contains(e.target)) stageTrackerCloseMenu(false); }; m.onKey = e => { if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); stageTrackerCloseMenu(true); return; } @@ -23474,7 +23550,7 @@

All labels

case 'End': e.preventDefault(); stageTrackerMenuFocus(el, 'last'); break; case 'ArrowRight': if (b && b.getAttribute('aria-haspopup') === 'menu' && b.getAttribute('aria-disabled') !== 'true') { e.preventDefault(); b.setAttribute('aria-expanded', 'true'); stageTrackerMenuFocus(el, 1, b); } break; case 'ArrowLeft': { const sub = b && b.closest('.ham-submenu'); if (sub && sub.previousElementSibling) { e.preventDefault(); sub.previousElementSibling.setAttribute('aria-expanded', 'false'); sub.previousElementSibling.focus(); } break; } - case 'Tab': stageTrackerCloseMenu(true); break; + case 'Tab': if (!sheet) stageTrackerCloseMenu(true); break; } }; el.addEventListener('click', e => { @@ -23491,10 +23567,12 @@

All labels

stageTrackerCloseMenu(true); stageTrackerDoAction(m.items, act); }); - document.addEventListener('pointerdown', m.onAway, true); + if (!sheet) { + document.addEventListener('pointerdown', m.onAway, true); + window.addEventListener('resize', m.onAway); + window.addEventListener('scroll', m.onAway, true); + } document.addEventListener('keydown', m.onKey, true); - window.addEventListener('resize', m.onAway); - window.addEventListener('scroll', m.onAway, true); _stageTrackerMenu = m; stageTrackerSetMenuOpen(document.getElementById('activity-monitor-panel'), true); if (at.expandDecide) { const d = el.querySelector('[data-ham-act="decide"]'); if (d && d.getAttribute('aria-disabled') !== 'true') d.setAttribute('aria-expanded', 'true'); } @@ -26278,10 +26356,13 @@

All labels

} function stageTrackerTerminalView(d, nowMs) { if (!d || !Array.isArray(d.items)) return d; + // Merge state is null until its first fetch lands; a row menu can be + // opened before then, so read it as "nothing merged yet". + const merged = _stageTrackerMergeState || {}; const items = d.items.map(item => { const rowKey = stageTrackerItemKey(item), pin = _stageTrackerCelebrating[rowKey]; const active = pin && pin.until > nowMs; - if (item.kind === 'pr' && _stageTrackerMergeState[rowKey] === true) { + if (item.kind === 'pr' && merged[rowKey] === true) { const fact = _stageTrackerTerminalFacts[rowKey]; return (fact && fact.until > nowMs) || Number(item.stage) >= STAGE_TRACKER_TERMINAL ? stageTrackerTerminalItem(item, rowKey) : null; } @@ -26295,7 +26376,7 @@

All labels

} const linked = source.map(lp => { const key = stageTrackerItemKey(stageTrackerLinkedPRItem(item, lp)); - if (_stageTrackerMergeState[key] !== true) return lp; + if (merged[key] !== true) return lp; const fact = _stageTrackerTerminalFacts[key]; return (fact && fact.until > nowMs) || Number(lp.stage) >= STAGE_TRACKER_TERMINAL ? stageTrackerTerminalItem(lp, key) : null; }).filter(Boolean); diff --git a/src/pkg/dashboard/webstatic/testdata/tracker-phone-ergonomics.js b/src/pkg/dashboard/webstatic/testdata/tracker-phone-ergonomics.js new file mode 100644 index 0000000000..d749ff9f4a --- /dev/null +++ b/src/pkg/dashboard/webstatic/testdata/tracker-phone-ergonomics.js @@ -0,0 +1,86 @@ +// Dedicated preview only: evaluate ()({ dedicatedPreview: true }). +// Phone ergonomics gate for the activity monitor (#17158). Asserts only at the +// 390Γ—844 phone viewport (dashboard-mobile-shots.mjs runs probes at every +// viewport); elsewhere it reports { skipped: true } so desktop stays a +// no-diff. Opens and closes the first row's β‹― menu via its public entry +// point; never activates a menu item or changes rows. +(async ({ dedicatedPreview = false } = {}) => { + if (!dedicatedPreview) throw new Error('Use a dedicated published-preview tab, not the user’s live dashboard'); + const PHONE = { width: 390, height: 844 }; + if (innerWidth !== PHONE.width || innerHeight !== PHONE.height) return { skipped: true, viewport: [innerWidth, innerHeight] }; + const section = document.getElementById('activity-monitor-section'); + if (!section) throw new Error('#activity-monitor-section missing'); + const failures = []; + const assert = (ok, label) => { if (!ok) failures.push(label); }; + const tolerance = 0.5; + // #17163: Apple HIG / WCAG 2.5.5 coarse-pointer floor, the value base.css + // publishes as --tap-target-touch and the phone tier remaps --tap-target to. + const tapTarget = parseFloat(getComputedStyle(section).getPropertyValue('--tap-target')) || 0; + assert(tapTarget >= 44 - tolerance, `--tap-target on the section is ${tapTarget}px, want β‰₯ 44px`); + const visible = el => el.getClientRects().length && getComputedStyle(el).visibility !== 'hidden'; + // Exclusions: inline text links (issue / PR refs, prose anchors) and the + // inline chevron-word decision triggers flow with their text and cannot + // be 44px tall without breaking the line (tracker-decision-interaction + // hit-tests the triggers on their own terms); the + // chevron-strip info cells fill their strip cell, whose height is the + // row-strip layout (#17162), not a control size. Everything else is a + // block-ish control and must meet the floor. + const inlineText = el => (getComputedStyle(el).display === 'inline' && el.matches('a, button.ham-decision-trigger')) + || el.matches('a.ham-ref, a.ham-pr-ref'); + const stripCell = el => el.matches('.ham-chevron-info, .ham-chevron-decision, .ham-chevron-copy .ham-decision-trigger'); + const controls = [...section.querySelectorAll('button, a[href], input, select, summary, [role="button"], [role="menuitem"], [tabindex]:not([tabindex="-1"]):not(.ham-row):not(.ham-sub)')] + .filter(el => visible(el) && !inlineText(el) && !stripCell(el)); + const small = []; + for (const el of controls) { + const r = el.getBoundingClientRect(); + if (r.width + tolerance < 44 || r.height + tolerance < 44) small.push(`${el.tagName.toLowerCase()}.${[...el.classList].join('.')} ${Math.round(r.width)}Γ—${Math.round(r.height)}`); + } + assert(small.length === 0, `${small.length} control(s) under 44Γ—44 at 390Γ—844: ${[...new Set(small)].slice(0, 12).join(', ')}`); + // Row tools live in the row header, not the (hidden) left gutter. + const row = section.querySelector('.ham-row'); + const tools = row && row.querySelector(':scope > .ham-row-tools'); + const head = row && row.querySelector(':scope > .ham-row-head'); + assert(!!(tools && head), 'first row has .ham-row-tools and .ham-row-head'); + if (tools && head) { + const t = tools.getBoundingClientRect(), h = head.getBoundingClientRect(), rr = row.getBoundingClientRect(); + assert(t.left >= rr.left - tolerance, `row tools start inside the row (left ${Math.round(t.left)} vs row ${Math.round(rr.left)})`); + assert(t.right <= rr.right + tolerance, 'row tools end inside the row'); + assert(t.top >= rr.top - tolerance && t.top <= h.bottom + tolerance, 'row tools sit on the row header line'); + for (const b of tools.querySelectorAll('.ham-sel, .ham-kebab')) assert(parseFloat(getComputedStyle(b).opacity) === 1, `${b.className} is always visible on a phone`); + } + // β‹― opens as a .hive-dialog.modal-sheet (not the anchored popover). + // Open the first row kebab that has menu targets (fixture rows without a + // resolvable terminal view have none), through the same click path a + // thumb takes. + let kebab = null; + if (typeof stageTrackerMenuTargets === 'function') { + for (const k of section.querySelectorAll('.ham-row > .ham-row-tools > .ham-kebab')) { + let t = null; + try { t = stageTrackerMenuTargets(k); } catch (e) { t = null; } + if (t && t.items && t.items.length) { kebab = k; break; } + } + } + let menu = { opened: false }; + if (kebab && typeof stageTrackerOpenMenu === 'function' && typeof stageTrackerCloseMenu === 'function') { + kebab.click(); + await new Promise(requestAnimationFrame); + const el = document.querySelector('.ham-menu'); + const sheet = el && el.closest('.hive-dialog.modal-sheet'); + assert(!!el, 'kebab opens a .ham-menu'); + assert(!!sheet, 'phone kebab menu is hosted in a .hive-dialog.modal-sheet'); + if (el) { + // Collapsed submenu items (e.g. "Decide PR β–Έ") have no box until opened. + const items = [...el.querySelectorAll('[role="menuitem"]')].filter(i => i.getClientRects().length); + const shortItems = items.filter(i => i.getBoundingClientRect().height + tolerance < 44).length; + assert(shortItems === 0, `${shortItems} menu item(s) shorter than 44px`); + const r = (sheet || el).getBoundingClientRect(); + assert(r.left >= -tolerance && r.right <= innerWidth + tolerance, 'menu sheet fits the viewport width'); + menu = { opened: true, sheet: !!sheet, items: items.length }; + } + stageTrackerCloseMenu(false); + await new Promise(requestAnimationFrame); + assert(!document.querySelector('.ham-menu'), 'menu closes cleanly'); + } else assert(false, 'kebab button and menu entry points present'); + if (failures.length) throw new Error(JSON.stringify({ probe: 'tracker-phone-ergonomics', failures })); + return { ok: true, tapTarget, controls: controls.length, menu }; +}) diff --git a/src/scripts/dashboard-mobile-shots.mjs b/src/scripts/dashboard-mobile-shots.mjs index cba2fc569a..7abff7b18f 100644 --- a/src/scripts/dashboard-mobile-shots.mjs +++ b/src/scripts/dashboard-mobile-shots.mjs @@ -267,7 +267,7 @@ async function main() { const activityFailures = []; const fixtureRoot = path.join(process.cwd(), 'src/pkg/dashboard/webstatic/testdata'); const density = JSON.parse(fs.readFileSync(path.join(fixtureRoot, 'tracker-activity-density.json'), 'utf8')); - const probes = ['tracker-header-geometry', 'tracker-decision-interaction', 'tracker-phone-chrome', 'tracker-phone-pill'].map(name => ({ + const probes = ['tracker-header-geometry', 'tracker-decision-interaction', 'tracker-phone-chrome', 'tracker-phone-pill', 'tracker-phone-ergonomics'].map(name => ({ name, source: fs.readFileSync(path.join(fixtureRoot, name + '.js'), 'utf8'), })); // Phone tier (hivecommons/hive#17160): the chevron strip is hidden behind