[ACS-9702] Restore focus after closing dialog (#4590)

* [ACS-9702] restore focus after closing dialog

* [ACS-9702] link ticket to excluded test
This commit is contained in:
Mykyta Maliarchuk 2025-06-02 11:50:16 +02:00 committed by GitHub
parent 377cfae13a
commit 8c3bf4738f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 4 deletions

View File

@ -210,7 +210,7 @@ describe('ManageRulesSmartComponent', () => {
expect(ruleDetails).toBeFalsy();
});
// TODO: flaky test that needs review
// TODO: [ACS-9719] flaky test that needs review
// eslint-disable-next-line ban/ban
xit('should call deleteRule() if confirmation dialog returns true', () => {
const dialog = TestBed.inject(MatDialog);

View File

@ -223,7 +223,8 @@ export class ManageRulesSmartComponent implements OnInit {
title: 'ACA_FOLDER_RULES.CONFIRMATION_DIALOG.DELETE_RULE.TITLE',
message: 'ACA_FOLDER_RULES.CONFIRMATION_DIALOG.DELETE_RULE.MESSAGE'
},
minWidth: '346px'
minWidth: '346px',
restoreFocus: true
})
.afterClosed()
.subscribe((result) => {

View File

@ -53,7 +53,7 @@ import { AppHookService, AppSettingsService, ContentApiService } from '@alfresco
import { Store } from '@ngrx/store';
import { ContentManagementService } from './content-management.service';
import { NodeActionsService } from './node-actions.service';
import { DialogComponent, DialogSize, NotificationService, TranslationService } from '@alfresco/adf-core';
import { ConfirmDialogComponent, DialogComponent, DialogSize, NotificationService, TranslationService } from '@alfresco/adf-core';
import { MatDialog, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { MatSnackBarModule, MatSnackBarRef, SimpleSnackBar } from '@angular/material/snack-bar';
import { Node, NodeEntry, UserInfo, VersionPaging } from '@alfresco/js-api';
@ -1819,6 +1819,16 @@ describe('ContentManagementService', () => {
spyOn(elementToFocus, 'focus');
spyOn(document, 'querySelector').withArgs(elementToFocusSelector).and.returnValue(elementToFocus);
contentManagementService.leaveLibrary('', elementToFocusSelector);
expect(dialog.open).toHaveBeenCalledWith(ConfirmDialogComponent, {
data: {
title: 'APP.DIALOGS.CONFIRM_LEAVE.TITLE',
message: 'APP.DIALOGS.CONFIRM_LEAVE.MESSAGE',
yesLabel: 'APP.DIALOGS.CONFIRM_LEAVE.YES_LABEL',
noLabel: 'APP.DIALOGS.CONFIRM_LEAVE.NO_LABEL'
},
minWidth: '250px',
restoreFocus: true
});
afterClosed$.next();
expect(elementToFocus.focus).toHaveBeenCalled();
});

View File

@ -326,7 +326,8 @@ export class ContentManagementService {
yesLabel: 'APP.DIALOGS.CONFIRM_LEAVE.YES_LABEL',
noLabel: 'APP.DIALOGS.CONFIRM_LEAVE.NO_LABEL'
},
minWidth: '250px'
minWidth: '250px',
restoreFocus: true
});
dialogRef.afterClosed().subscribe((result) => {