From df521267ae1c288c8d7ebcf94c7a8e07e4be9789 Mon Sep 17 00:00:00 2001 From: Codeman maintainer Date: Thu, 22 Oct 2026 19:17:05 +0200 Subject: [PATCH] fix(file-viewer): keep the Expand label fixed while it is pressed Merge-time fix for #659. The Expand button swapped its title and aria-label to "Restore size" while on, so a screen reader announced "Restore size, pressed". The label now stays "Expand" and aria-pressed alone carries the state, the way the MD, Lines and Wrap toggles work. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/web/public/panels-ui.js | 10 +++------- test/file-preview-window.test.ts | 8 +++++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/web/public/panels-ui.js b/src/web/public/panels-ui.js index ed026845..dedaea57 100644 --- a/src/web/public/panels-ui.js +++ b/src/web/public/panels-ui.js @@ -4622,13 +4622,9 @@ Object.assign(CodemanApp.prototype, { const on = this._filePreviewPref('expanded'); const win = this.$('filePreviewOverlay')?.querySelector?.('.file-preview-window'); win?.classList?.toggle('expanded', on); - const btn = this.$('filePreviewExpandBtn'); - if (btn) { - btn.setAttribute('aria-pressed', on ? 'true' : 'false'); - const label = on ? 'Restore size' : 'Expand'; - btn.title = label; - btn.setAttribute('aria-label', label); - } + // The label stays "Expand" and aria-pressed carries the state, like MD, Lines and + // Wrap, so a screen reader never announces "Restore size, pressed". + this.$('filePreviewExpandBtn')?.setAttribute('aria-pressed', on ? 'true' : 'false'); }, /** diff --git a/test/file-preview-window.test.ts b/test/file-preview-window.test.ts index c29d25c4..bd9347dd 100644 --- a/test/file-preview-window.test.ts +++ b/test/file-preview-window.test.ts @@ -196,16 +196,22 @@ describe('file viewer back/forward', () => { describe('file viewer expand', () => { it('toggles the window class, the pref and the button state', () => { const { app, winClasses, store, expand } = loadApp(); + // As index.html ships it. + expand.title = 'Expand'; + expand.attrs['aria-label'] = 'Expand'; app.toggleFilePreviewExpanded(); expect(winClasses.has('expanded')).toBe(true); expect(store['codeman:filePreviewExpanded']).toBe('1'); expect(expand.attrs['aria-pressed']).toBe('true'); - expect(expand.title).toBe('Restore size'); + // aria-pressed carries the state; the label stays fixed, like the MD/Lines/Wrap toggles. + expect(expand.title).toBe('Expand'); + expect(expand.attrs['aria-label']).toBe('Expand'); app.toggleFilePreviewExpanded(); expect(winClasses.has('expanded')).toBe(false); expect(expand.attrs['aria-pressed']).toBe('false'); + expect(expand.title).toBe('Expand'); }); it('re-applies a remembered expanded state when a preview opens', async () => {