mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-18 04:09:33 +01:00
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) <noreply@anthropic.com>
This commit is contained in:
1 parent
e3c6f9f2c7
commit
df521267ae
2 files changed
+10
-8
No files matched your search
@@ -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');
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in new issue
Block a user