diff --git a/packages/agent-office/agent-office.test.mjs b/packages/agent-office/agent-office.test.mjs index 9c9eaeb..babc479 100644 --- a/packages/agent-office/agent-office.test.mjs +++ b/packages/agent-office/agent-office.test.mjs @@ -295,10 +295,18 @@ test("the Settings chevron and Language, Scene and Quality pickers are SVG app m expect(html).not.toContain("⌄") expect(html).not.toContain("]*>Settings<\/span>]*id="${btnId}"[^>]*aria-haspopup="listbox"[^>]*aria-expanded="false"[^>]*aria-controls="${listId}"[^>]*>.*]*id="${listId}"[^>]*role="listbox"`)) + for (const [lblId, btnId, listId] of [["lblLang", "optLang", "optLangList"], ["lblScene", "optScene", "optSceneList"], ["lblQuality", "optQuality", "optQualityList"]]) { + expect(html).toMatch(new RegExp(`]*id="${btnId}"[^>]*aria-labelledby="${lblId} ${btnId}"[^>]*aria-haspopup="listbox"[^>]*aria-expanded="false"[^>]*aria-controls="${listId}"[^>]*>.*]*id="${listId}"[^>]*role="listbox"[^>]*aria-labelledby="${lblId}"`)) } + expect(css).toContain("--faint: var(--magpie-faint, #b9b9c2);") + expect(css).toMatch(/\[data-theme="dark"\][^{]*\{[^}]*--faint:\s*var\(--magpie-faint,\s*#56565f\);/) + expect(css).toMatch(/::-webkit-scrollbar\s*\{\s*width:\s*8px;\s*height:\s*8px;\s*background:\s*transparent;\s*\}/) + expect(css).toMatch(/::-webkit-scrollbar-thumb\s*\{\s*background:\s*var\(--faint\);\s*border:\s*2px solid transparent;\s*border-radius:\s*8px;\s*background-clip:\s*padding-box;\s*\}/) + expect(css).toMatch(/::-webkit-scrollbar-thumb:hover\s*\{\s*background-color:\s*var\(--muted\);\s*\}/) + expect(css).toMatch(/::-webkit-scrollbar-button,\s*::-webkit-scrollbar-corner\s*\{\s*display:\s*none;\s*background:\s*transparent;\s*\}/) + expect(css).not.toContain("scrollbar-width") + expect(css).toMatch(/\.picker-list\s*\{[^}]*overscroll-behavior:\s*contain;/) expect(css).toMatch(/\.btn\s*\{[^}]*display:\s*inline-flex;[^}]*align-items:\s*center;[^}]*gap:\s*7px;/) expect(css).toContain(".today-tokens:empty { display: none; }") expect(css).toContain('#settingsBtn[aria-expanded="true"] .chev, .lang-select[aria-expanded="true"] .chev { transform: rotate(180deg); }') diff --git a/packages/agent-office/page/app.js b/packages/agent-office/page/app.js index 457bee6..e6b9963 100644 --- a/packages/agent-office/page/app.js +++ b/packages/agent-office/page/app.js @@ -763,6 +763,10 @@ const QUALITY_OPTIONS = [["low", "qLow"], ["medium", "qMedium"], ["high", "qHigh"]] const pickers = [] let openPicker = null + let pickerOpeningFrame = 0 + function clearPickerOpening() { + if (pickerOpeningFrame) { cancelAnimationFrame(pickerOpeningFrame); pickerOpeningFrame = 0 } + } function checkIcon() { const ns = "http://www.w3.org/2000/svg" const s = document.createElementNS(ns, "svg") @@ -847,7 +851,10 @@ list.style.maxHeight = maxH + "px" } function close(refocus) { - if (openPicker === api) openPicker = null + if (openPicker === api) { + openPicker = null + clearPickerOpening() + } list.hidden = true btn.setAttribute("aria-expanded", "false") list.removeAttribute("aria-activedescendant") @@ -864,6 +871,8 @@ list.hidden = false btn.setAttribute("aria-expanded", "true") openPicker = api + clearPickerOpening() + pickerOpeningFrame = requestAnimationFrame(() => { pickerOpeningFrame = 0 }) position() setActive(idx) list.focus({ preventScroll: true }) @@ -1106,7 +1115,13 @@ $("settingsBtn").addEventListener("click", (e) => { e.stopPropagation(); toggleMenu($("settingsBtn"), menu) }) $("todayBtn").addEventListener("click", (e) => { e.stopPropagation(); toggleMenu($("todayBtn"), todayMenu) }) menu.addEventListener("click", (e) => e.stopPropagation()) - menu.addEventListener("scroll", () => closePicker(false)) + // Focusing a picker button near the foot of a scrollable #settings menu + // queues an async scroll event on #settings for the same frame; reposition + // the newly opened list instead of closing it on that opening-frame scroll. + menu.addEventListener("scroll", () => { + if (pickerOpeningFrame) { if (openPicker) openPicker.position(); return } + closePicker(false) + }) todayMenu.addEventListener("click", (e) => e.stopPropagation()) addEventListener("pointerdown", (e) => { if (openPicker && !openPicker.wrap.contains(e.target)) closePicker(false) diff --git a/packages/agent-office/page/index.html b/packages/agent-office/page/index.html index dbc972b..67e8583 100644 --- a/packages/agent-office/page/index.html +++ b/packages/agent-office/page/index.html @@ -4,7 +4,7 @@ Agent Office - + @@ -12,7 +12,7 @@ - +
@@ -59,21 +59,21 @@
Language
- +
Scene
- +
Quality
- +
diff --git a/packages/agent-office/page/style.css b/packages/agent-office/page/style.css index 7344bce..3d3570e 100644 --- a/packages/agent-office/page/style.css +++ b/packages/agent-office/page/style.css @@ -3,6 +3,7 @@ --card: var(--magpie-card, #f6f6f7); --fg: var(--magpie-fg, #1d1d1f); --muted: var(--magpie-muted, #6e6e73); + --faint: var(--magpie-faint, #b9b9c2); --line: var(--magpie-line, #e5e5ea); --accent: var(--magpie-accent, #4f46e5); --font: var(--magpie-font, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif); @@ -10,7 +11,7 @@ --sheet: var(--card); --think: #8b6cf6; --exec: #3b82f6; --reply: #10b981; --wait: #f59e0b; --done: #22a35a; --err: #ef4444; } -[data-theme="dark"] { --sheet: #1c1c1f; } +[data-theme="dark"] { --faint: var(--magpie-faint, #56565f); --sheet: #1c1c1f; } * { box-sizing: border-box; } [hidden] { display: none !important; } /* the page paints no background of its own: magpie's shows through, so @@ -20,6 +21,10 @@ html, body { margin: 0; height: 100%; overflow: hidden; background: transparent; window's inset shows no ring of a different colour */ body { padding: 18px 24px 12px; font: 13px/1.45 var(--font); } button { font: inherit; color: inherit; } +::-webkit-scrollbar { width: 8px; height: 8px; background: transparent; } +::-webkit-scrollbar-thumb { background: var(--faint); border: 2px solid transparent; border-radius: 8px; background-clip: padding-box; } +::-webkit-scrollbar-thumb:hover { background-color: var(--muted); } +::-webkit-scrollbar-button, ::-webkit-scrollbar-corner { display: none; background: transparent; } .card { display: flex; flex-direction: column; height: 100%; min-height: 0; } body.panel, .card { background: none; } @@ -204,7 +209,7 @@ footer { padding-top: 12px; display: flex; flex-direction: column; gap: 8px; } .lang-select { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); font: inherit; font-size: 13px; text-align: left; cursor: pointer; } .lang-select:hover, .lang-select[aria-expanded="true"] { border-color: var(--muted); } .picker-val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } -.picker-list { position: fixed; z-index: 60; display: flex; flex-direction: column; gap: 1px; max-width: min(320px, calc(100vw - 16px)); max-height: 240px; overflow: auto; padding: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(0, 0, 0, .2); outline: none; } +.picker-list { position: fixed; z-index: 60; display: flex; flex-direction: column; gap: 1px; max-width: min(320px, calc(100vw - 16px)); max-height: 240px; overflow: auto; overscroll-behavior: contain; padding: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(0, 0, 0, .2); outline: none; } .picker-opt { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: 7px; background: none; color: var(--fg); font: inherit; font-size: 13px; text-align: left; cursor: pointer; } .picker-opt:hover, .picker-opt.active { background: var(--card); } .picker-opt[aria-selected="true"] { font-weight: 600; } diff --git a/packages/agent-office/test/browser.mjs b/packages/agent-office/test/browser.mjs index 7e6285c..975b5a9 100644 --- a/packages/agent-office/test/browser.mjs +++ b/packages/agent-office/test/browser.mjs @@ -61,13 +61,27 @@ for(const engine of (process.env.OFFICE_BROWSERS||'chromium,webkit').split(',')) const bounds=await frame.locator('#'+id).evaluate(e=>{const r=e.getBoundingClientRect();return {left:r.left,right:r.right,top:r.top,bottom:r.bottom,w:innerWidth,h:innerHeight}}) assert(bounds.left>=0&&bounds.right<=bounds.w+1&&bounds.top>=0&&bounds.bottom<=bounds.h+1,`${engine} menu ${JSON.stringify(bounds)}`) if(id==='settings') { - await frame.locator('#optQuality').scrollIntoViewIfNeeded() - await frame.locator('#optQuality').click() + const sceneA11y=await frame.evaluate(()=>`${document.querySelector('#lblScene').textContent.trim()} ${document.querySelector('#optScene .picker-val').textContent.trim()}`) + assert((await frame.locator('#settings').ariaSnapshot()).includes(`button "${sceneA11y}"`),`${engine} picker accessible name ${sceneA11y}`) + await frame.locator('#optQuality').focus() + await page.keyboard.press('Enter') + assert.equal(await frame.locator('#optQualityList').isVisible(),true,`${engine} same-frame focus+Enter keeps picker open`) const pb=await frame.locator('#optQualityList').evaluate(e=>{const r=e.getBoundingClientRect();return {left:r.left,right:r.right,top:r.top,bottom:r.bottom,w:innerWidth,h:innerHeight}}) assert(pb.left>=0&&pb.right<=pb.w+1&&pb.top>=0&&pb.bottom<=pb.h+1,`${engine} picker ${JSON.stringify(pb)}`) await page.keyboard.press('Escape') assert.equal(await frame.locator('#optQualityList').isVisible(),false) assert.equal(await frame.locator('#settings').isVisible(),true) + await frame.locator('#optScene').click() + const sceneBar=await frame.locator('#optSceneList').evaluate(e=>({overscroll:getComputedStyle(e).overscrollBehaviorY,width:getComputedStyle(e,'::-webkit-scrollbar').width,thumb:getComputedStyle(e,'::-webkit-scrollbar-thumb').backgroundColor})) + assert.equal(sceneBar.overscroll,'contain') + assert.equal(sceneBar.width,'8px') + assert.notEqual(sceneBar.thumb,'rgba(0, 0, 0, 0)') + const sceneBox=await frame.locator('#optSceneList').boundingBox() + await page.mouse.move(sceneBox.x+sceneBox.width/2,sceneBox.y+sceneBox.height/2) + await page.mouse.wheel(0,600) + await page.mouse.wheel(0,600) + assert.equal(await frame.locator('#optSceneList').isVisible(),true,`${engine} wheel overscroll keeps picker open`) + await page.keyboard.press('Escape') } await page.screenshot({path:`${output}/${engine}-${width}-${id}.png`}) await frame.locator(id==='settings'?'#settingsBtn':'#todayBtn').click() @@ -105,6 +119,9 @@ for(const engine of (process.env.OFFICE_BROWSERS||'chromium,webkit').split(',')) await frame.locator('#settingsBtn').click() } await frame.locator('[data-mode="list"]').click() + const listBar=await frame.locator('#listview').evaluate(e=>({width:getComputedStyle(e,'::-webkit-scrollbar').width,thumb:getComputedStyle(e,'::-webkit-scrollbar-thumb').backgroundColor})) + assert.equal(listBar.width,'8px') + assert.notEqual(listBar.thumb,'rgba(0, 0, 0, 0)') const buffer=await frame.locator('#office3d').evaluate(e=>[e.width,e.height]) await frame.evaluate(()=>{for(let i=0;i<5;i++)dispatchEvent(new Event('resize'));document.dispatchEvent(new Event('visibilitychange'))}) assert.deepEqual(await frame.locator('#office3d').evaluate(e=>[e.width,e.height]),buffer)