diff --git a/projects/aca-content/src/lib/services/content-management.service.ts b/projects/aca-content/src/lib/services/content-management.service.ts index 7dcb51cfff..d000efba0b 100644 --- a/projects/aca-content/src/lib/services/content-management.service.ts +++ b/projects/aca-content/src/lib/services/content-management.service.ts @@ -85,7 +85,7 @@ interface RestoredNode { providedIn: 'root' }) export class ContentManagementService { - private readonly createMenuButtonSelector = 'app-create-menu button'; + private readonly createMenuButtonSelector = 'app-toolbar-menu button[id="app.toolbar.create"]'; constructor( private nodesApiService: NodesApiService, diff --git a/projects/aca-content/src/lib/services/node-template.service.ts b/projects/aca-content/src/lib/services/node-template.service.ts index 541b69f38f..c38177e226 100644 --- a/projects/aca-content/src/lib/services/node-template.service.ts +++ b/projects/aca-content/src/lib/services/node-template.service.ts @@ -166,6 +166,6 @@ export class NodeTemplateService { } private static focusCreateMenuButton(): void { - document.querySelector('app-create-menu button').focus(); + document.querySelector('app-toolbar-menu button[id="app.toolbar.create"]').focus(); } } diff --git a/projects/aca-content/src/lib/store/effects/upload.effects.spec.ts b/projects/aca-content/src/lib/store/effects/upload.effects.spec.ts index f24bcdb01c..922b789a64 100644 --- a/projects/aca-content/src/lib/store/effects/upload.effects.spec.ts +++ b/projects/aca-content/src/lib/store/effects/upload.effects.spec.ts @@ -59,76 +59,76 @@ describe('UploadEffects', () => { }); describe('uploadFiles$', () => { - let createMenuButton: HTMLButtonElement; + let uploadMenuButton: HTMLButtonElement; const focusedClass = 'cdk-program-focused'; beforeEach(() => { - createMenuButton = document.createElement('button'); - document.body.appendChild(createMenuButton); + uploadMenuButton = document.createElement('button'); + document.body.appendChild(uploadMenuButton); store.dispatch(new UploadFilesAction({})); - spyOn(document, 'querySelector').withArgs('app-create-menu button').and.returnValue(createMenuButton); + spyOn(document, 'querySelector').withArgs('app-toolbar-menu button[id="app.toolbar.upload"]').and.returnValue(uploadMenuButton); }); - it('should call focus function on create menu button', () => { - spyOn(createMenuButton, 'focus'); + it('should call focus function on upload menu button', () => { + spyOn(uploadMenuButton, 'focus'); window.dispatchEvent(new FocusEvent('focus')); - expect(createMenuButton.focus).toHaveBeenCalledWith(); + expect(uploadMenuButton.focus).toHaveBeenCalledWith(); }); - it('should not call focus function on create menu button if handler for focus of window is not fired', () => { - spyOn(createMenuButton, 'focus'); - expect(createMenuButton.focus).not.toHaveBeenCalled(); + it('should not call focus function on upload menu button if handler for focus of window is not fired', () => { + spyOn(uploadMenuButton, 'focus'); + expect(uploadMenuButton.focus).not.toHaveBeenCalled(); }); - it('should add cdk-program-focused class to create menu button', () => { + it('should add cdk-program-focused class to upload menu button', () => { window.dispatchEvent(new FocusEvent('focus')); - createMenuButton.dispatchEvent(new FocusEvent('focus')); - expect(createMenuButton).toHaveClass(focusedClass); + uploadMenuButton.dispatchEvent(new FocusEvent('focus')); + expect(uploadMenuButton).toHaveClass(focusedClass); }); - it('should not add cdk-program-focused class to create menu button if handler for focus of window is not fired', () => { - expect(createMenuButton).not.toHaveClass(focusedClass); + it('should not add cdk-program-focused class to upload menu button if handler for focus of window is not fired', () => { + expect(uploadMenuButton).not.toHaveClass(focusedClass); }); afterEach(() => { - createMenuButton.remove(); + uploadMenuButton.remove(); }); }); describe('uploadFolder$', () => { - let createMenuButton: HTMLButtonElement; + let uploadMenuButton: HTMLButtonElement; const focusedClass = 'cdk-program-focused'; beforeEach(() => { - createMenuButton = document.createElement('button'); - document.body.appendChild(createMenuButton); + uploadMenuButton = document.createElement('button'); + document.body.appendChild(uploadMenuButton); store.dispatch(new UploadFolderAction({})); - spyOn(document, 'querySelector').withArgs('app-create-menu button').and.returnValue(createMenuButton); + spyOn(document, 'querySelector').withArgs('app-toolbar-menu button[id="app.toolbar.upload"]').and.returnValue(uploadMenuButton); }); - it('should call focus function on create menu button', () => { - spyOn(createMenuButton, 'focus'); + it('should call focus function on upload menu button', () => { + spyOn(uploadMenuButton, 'focus'); window.dispatchEvent(new FocusEvent('focus')); - expect(createMenuButton.focus).toHaveBeenCalledWith(); + expect(uploadMenuButton.focus).toHaveBeenCalledWith(); }); - it('should not call focus function on create menu button if handler for focus of window is not fired', () => { - spyOn(createMenuButton, 'focus'); - expect(createMenuButton.focus).not.toHaveBeenCalled(); + it('should not call focus function on upload menu button if handler for focus of window is not fired', () => { + spyOn(uploadMenuButton, 'focus'); + expect(uploadMenuButton.focus).not.toHaveBeenCalled(); }); - it('should add cdk-program-focused class to create menu button', () => { + it('should add cdk-program-focused class to upload menu button', () => { window.dispatchEvent(new FocusEvent('focus')); - createMenuButton.dispatchEvent(new FocusEvent('focus')); - expect(createMenuButton).toHaveClass(focusedClass); + uploadMenuButton.dispatchEvent(new FocusEvent('focus')); + expect(uploadMenuButton).toHaveClass(focusedClass); }); - it('should not add cdk-program-focused class to create menu button if handler for focus of window is not fired', () => { - expect(createMenuButton).not.toHaveClass(focusedClass); + it('should not add cdk-program-focused class to upload menu button if handler for focus of window is not fired', () => { + expect(uploadMenuButton).not.toHaveClass(focusedClass); }); afterEach(() => { - createMenuButton.remove(); + uploadMenuButton.remove(); }); }); diff --git a/projects/aca-content/src/lib/store/effects/upload.effects.ts b/projects/aca-content/src/lib/store/effects/upload.effects.ts index 153107ccdf..18db21aed3 100644 --- a/projects/aca-content/src/lib/store/effects/upload.effects.ts +++ b/projects/aca-content/src/lib/store/effects/upload.effects.ts @@ -47,7 +47,7 @@ export class UploadEffects { private fileInput: HTMLInputElement; private folderInput: HTMLInputElement; private fileVersionInput: HTMLInputElement; - private readonly createMenuButtonSelector = 'app-create-menu button'; + private readonly uploadMenuButtonSelector = 'app-toolbar-menu button[id="app.toolbar.upload"]'; constructor( private store: Store, @@ -91,7 +91,7 @@ export class UploadEffects { this.actions$.pipe( ofType(UploadActionTypes.UploadFiles), map(() => { - this.registerFocusingElementAfterModalClose(this.fileInput, this.createMenuButtonSelector); + this.registerFocusingElementAfterModalClose(this.fileInput, this.uploadMenuButtonSelector); this.fileInput.click(); }) ), @@ -103,7 +103,7 @@ export class UploadEffects { this.actions$.pipe( ofType(UploadActionTypes.UploadFolder), map(() => { - this.registerFocusingElementAfterModalClose(this.folderInput, this.createMenuButtonSelector); + this.registerFocusingElementAfterModalClose(this.folderInput, this.uploadMenuButtonSelector); this.folderInput.click(); }) ),