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,
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';
}