From a8ddca86ee0af05b5fd0ef46f736551c7dd8dd58 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Thu, 26 Nov 2026 14:14:35 +0100 Subject: [PATCH 1/4] Return focus to Preview when the file preview closes The close control is hidden with the preview panel, so focus fell to the page body. Co-Authored-By: Claude Opus 5.5 --- .../file-description.component.html | 8 ++++---- .../file-description.component.spec.ts | 17 +++++++++++++++++ .../file-description.component.ts | 11 +++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.html b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.html index 668137316a0..2ee9cd5c2fb 100644 --- a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.html +++ b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.html @@ -54,7 +54,7 @@ @if (couldPreview()) { -   {{'item.file.description.file.preview' | translate}} diff --git a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.spec.ts b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.spec.ts index d539634ac6b..bce564c5a35 100644 --- a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.spec.ts +++ b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.spec.ts @@ -427,6 +427,23 @@ describe('FileDescriptionComponent', () => { expect(previewButton().getAttribute('aria-expanded')).toEqual('false'); }); + it('moves focus back to Preview when the close control closes the panel', () => { + ['Enter', ' '].forEach((key: string) => { + previewButton().click(); + fixture.detectChanges(); + closeButton().focus(); + expect(document.activeElement).withContext('the close control cannot take focus').toBe(closeButton()); + + closeButton().dispatchEvent(new KeyboardEvent('keyup', { key, bubbles: true })); + fixture.detectChanges(); + + expect(isVisible(panel())).toBeFalse(); + expect(document.activeElement) + .withContext(`after closing with "${key}" focus is on ${document.activeElement?.tagName}, not on Preview`) + .toBe(previewButton()); + }); + }); + it('does not scroll the page when Space is pressed on Preview', () => { expect(dispatchSpaceKey(previewButton(), 'keydown').defaultPrevented).toBeTrue(); }); diff --git a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.ts b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.ts index 42df5916cc3..ed9a2449eb0 100644 --- a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.ts +++ b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.ts @@ -89,6 +89,8 @@ export class FileDescriptionComponent implements OnInit, OnDestroy, AfterViewIni @ViewChild('videoPreview') videoElement: ElementRef; + @ViewChild('previewButton') previewButton: ElementRef; + previewCollapsed = true; emailToContact: string; @@ -287,6 +289,15 @@ export class FileDescriptionComponent implements OnInit, OnDestroy, AfterViewIni this.previewCollapsed = !this.previewCollapsed; } + /** + * Closes the preview from the control inside the panel. That control is hidden with the panel, + * so focus goes back to the Preview control instead of falling to the page body. + */ + public closePreview() { + this.previewCollapsed = true; + this.previewButton?.nativeElement.focus(); + } + public isTxt() { return this.fileInput?.format === 'text/plain'; } From 4519df71841b572063fa195fa16b2d2c5030f81b Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Thu, 26 Nov 2026 14:14:52 +0100 Subject: [PATCH 2/4] Keep the MD5 value on its row when a file has no description An empty value now clears its floated label, as Bootstrap 3 dl-horizontal did. Co-Authored-By: Claude Opus 5.5 --- .../file-description.component.scss | 5 +++++ .../file-description.component.spec.ts | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.scss b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.scss index 35246dea3f5..3d7155c34fc 100644 --- a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.scss +++ b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.scss @@ -39,6 +39,11 @@ } } + // Clears the floated dt, so an empty dd still fills its row. + .dl-horizontal dd { + @include clearfix(); + } + .preview-image { width: 10%; diff --git a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.spec.ts b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.spec.ts index bce564c5a35..84203dae4f6 100644 --- a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.spec.ts +++ b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.spec.ts @@ -169,6 +169,21 @@ describe('FileDescriptionComponent', () => { expect(fileNameElement.textContent).toContain('testFile'); }); + it('lets an empty value clear its floated label, so the MD5 value stays on its own row', () => { + component.fileInput.description = ''; + fixture.detectChanges(); + + const label: HTMLElement = Array.from(fixture.nativeElement.querySelectorAll('.file-content dt')) + .find((dt: HTMLElement) => dt.textContent.includes('item.file.description.description')); + const emptyValue = label.nextElementSibling as HTMLElement; + expect(emptyValue.textContent.trim()).toEqual(''); + + // Karma's window is narrower than the 768px side-by-side layout, so this checks the rule, not the rows. + const after = getComputedStyle(emptyValue, '::after'); + expect(after.content).withContext('the empty value has no box that clears the label').not.toEqual('none'); + expect(after.clear).toEqual('both'); + }); + describe('the download control', () => { const downloadButton = (): HTMLElement => fixture.nativeElement.querySelector('a.download-btn'); const downloadRoute = (): string[] => ['bitstreams', component.fileInput.id, 'download']; From 0244233512d4002f0e7a1582c88d71a24a95dbec Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Thu, 26 Nov 2026 14:14:57 +0100 Subject: [PATCH 3/4] Keep community tree levels right after the tree reloads The tree now keys rows by id, so kept rows no longer report aria-level 1. Co-Authored-By: Claude Opus 5.5 --- .../community-list.component.html | 2 +- .../community-list.component.spec.ts | 42 +++++++++++++++++++ .../community-list.component.ts | 3 ++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/app/community-list-page/community-list/community-list.component.html b/src/app/community-list-page/community-list/community-list.component.html index 30b3bcc31f5..ebf5df5d44b 100644 --- a/src/app/community-list-page/community-list/community-list.component.html +++ b/src/app/community-list-page/community-list/community-list.component.html @@ -1,7 +1,7 @@ @if ((dataSource.loading$ | async) && !loadingNode) { } - + diff --git a/src/app/community-list-page/community-list/community-list.component.spec.ts b/src/app/community-list-page/community-list/community-list.component.spec.ts index f71db2a36d2..0f400c535fd 100644 --- a/src/app/community-list-page/community-list/community-list.component.spec.ts +++ b/src/app/community-list-page/community-list/community-list.component.spec.ts @@ -611,4 +611,46 @@ describe('CommunityListComponent', () => { }); }); }); + + describe('aria-level, aria-posinset and aria-setsize after the tree reloads', () => { + const rowFor = (name: string): HTMLElement => fixture.debugElement.queryAll(By.css('cdk-tree-node')) + .find((node: DebugElement) => node.query(By.css('a.lead'))?.nativeElement.textContent.trim() === name) + .nativeElement; + + const aria = (name: string): string[] => ['aria-level', 'aria-posinset', 'aria-setsize'] + .map((attribute: string) => rowFor(name).getAttribute(attribute)); + + const click = (button: HTMLElement): void => { + button.click(); + tick(); + fixture.detectChanges(); + }; + + const toggle = (name: string): HTMLElement => rowFor(name).querySelector('button[data-test="expand-button"]'); + + it('stay right on rows that were on screen before another community expanded', fakeAsync(() => { + click(toggle('community1')); + expect(aria('subcommunity1')).toEqual(['2', '1', '2']); + + click(toggle('community2')); + + expect(aria('community1')).toEqual(['1', '1', '3']); + expect(aria('subcommunity1')).toEqual(['2', '1', '2']); + expect(aria('subcommunity2')).toEqual(['2', '2', '2']); + expect(aria('community2')).toEqual(['1', '2', '3']); + expect(aria('collection1')).toEqual(['2', '1', '3']); + })); + + it('stay right on collections that were on screen before Show more', fakeAsync(() => { + click(toggle('community2')); + expect(aria('collection1')).toEqual(['2', '1', '3']); + + click(fixture.debugElement.query(By.css('.show-more-node [data-test="show-more-button"]')).nativeElement); + + expect(aria('collection1')).toEqual(['2', '1', '4']); + expect(aria('collection2')).toEqual(['2', '2', '4']); + expect(aria('collection3')).toEqual(['2', '3', '4']); + expect(aria('collection4')).toEqual(['2', '4', '4']); + })); + }); }); diff --git a/src/app/community-list-page/community-list/community-list.component.ts b/src/app/community-list-page/community-list/community-list.component.ts index cfd79743881..9b3f03d3a51 100644 --- a/src/app/community-list-page/community-list/community-list.component.ts +++ b/src/app/community-list-page/community-list/community-list.component.ts @@ -54,6 +54,9 @@ export class CommunityListComponent implements OnInit, OnDestroy { dataSource: CommunityListDatasource; paginationConfig: FindListOptions; trackBy = (index, node: FlatNode) => node.id; + // Every reload builds new node objects while kept rows hold their first one, so the tree + // must look up levels and positions by id too, or kept rows report aria-level 1. + expansionKey = (node: FlatNode) => node.id; constructor( protected communityListService: CommunityListService, From e93d9cd1825fe70db26dcf8000ffe7513e70bbaa Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Thu, 26 Nov 2026 23:05:52 +0100 Subject: [PATCH 4/4] Leave the MD5 row to the empty description fallback The port of the dtq-dev item page fixes shows N/A for an empty description, so the value is never empty and the MD5 row stays in place. Co-Authored-By: Claude Opus 5.5 --- .../file-description.component.scss | 5 ----- .../file-description.component.spec.ts | 15 --------------- 2 files changed, 20 deletions(-) diff --git a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.scss b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.scss index 3d7155c34fc..35246dea3f5 100644 --- a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.scss +++ b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.scss @@ -39,11 +39,6 @@ } } - // Clears the floated dt, so an empty dd still fills its row. - .dl-horizontal dd { - @include clearfix(); - } - .preview-image { width: 10%; diff --git a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.spec.ts b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.spec.ts index 84203dae4f6..bce564c5a35 100644 --- a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.spec.ts +++ b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.spec.ts @@ -169,21 +169,6 @@ describe('FileDescriptionComponent', () => { expect(fileNameElement.textContent).toContain('testFile'); }); - it('lets an empty value clear its floated label, so the MD5 value stays on its own row', () => { - component.fileInput.description = ''; - fixture.detectChanges(); - - const label: HTMLElement = Array.from(fixture.nativeElement.querySelectorAll('.file-content dt')) - .find((dt: HTMLElement) => dt.textContent.includes('item.file.description.description')); - const emptyValue = label.nextElementSibling as HTMLElement; - expect(emptyValue.textContent.trim()).toEqual(''); - - // Karma's window is narrower than the 768px side-by-side layout, so this checks the rule, not the rows. - const after = getComputedStyle(emptyValue, '::after'); - expect(after.content).withContext('the empty value has no box that clears the label').not.toEqual('none'); - expect(after.clear).toEqual('both'); - }); - describe('the download control', () => { const downloadButton = (): HTMLElement => fixture.nativeElement.querySelector('a.download-btn'); const downloadRoute = (): string[] => ['bitstreams', component.fileInput.id, 'download'];