-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make disabled menu bar buttons accessible with feature flag (#8518
- Loading branch information
Showing
11 changed files
with
534 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/menu-bar/test/accessible-disabled-buttons-lit.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import './not-animated-styles.js'; | ||
import '../vaadin-lit-menu-bar.js'; | ||
import './accessible-disabled-buttons.common.js'; |
3 changes: 3 additions & 0 deletions
3
packages/menu-bar/test/accessible-disabled-buttons-polymer.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import './not-animated-styles.js'; | ||
import '../vaadin-menu-bar.js'; | ||
import './accessible-disabled-buttons.common.js'; |
84 changes: 84 additions & 0 deletions
84
packages/menu-bar/test/accessible-disabled-buttons.common.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { expect } from '@vaadin/chai-plugins'; | ||
import { fixtureSync, middleOfNode, nextRender } from '@vaadin/testing-helpers'; | ||
import { resetMouse, sendKeys, sendMouse } from '@web/test-runner-commands'; | ||
|
||
describe('accessible disabled buttons', () => { | ||
let menuBar, buttons; | ||
|
||
before(() => { | ||
window.Vaadin.featureFlags ??= {}; | ||
window.Vaadin.featureFlags.accessibleDisabledButtons = true; | ||
}); | ||
|
||
after(() => { | ||
window.Vaadin.featureFlags.accessibleDisabledButtons = false; | ||
}); | ||
|
||
beforeEach(async () => { | ||
menuBar = fixtureSync('<vaadin-menu-bar></vaadin-menu-bar>'); | ||
menuBar.items = [ | ||
{ text: 'Item 0' }, | ||
{ text: 'Item 1', disabled: true, children: [{ text: 'SubItem 0' }] }, | ||
{ text: 'Item 2' }, | ||
]; | ||
await nextRender(menuBar); | ||
buttons = menuBar._buttons; | ||
}); | ||
|
||
afterEach(async () => { | ||
await resetMouse(); | ||
}); | ||
|
||
it('should not open sub-menu on disabled button click', async () => { | ||
const { x, y } = middleOfNode(buttons[1]); | ||
await sendMouse({ type: 'click', position: [Math.floor(x), Math.floor(y)] }); | ||
expect(buttons[1].hasAttribute('expanded')).to.be.false; | ||
}); | ||
|
||
it('should not open sub-menu on disabled button hover', async () => { | ||
menuBar.openOnHover = true; | ||
const { x, y } = middleOfNode(buttons[1]); | ||
await sendMouse({ type: 'move', position: [Math.floor(x), Math.floor(y)] }); | ||
expect(buttons[1].hasAttribute('expanded')).to.be.false; | ||
}); | ||
|
||
it('should include disabled buttons in arrow key navigation', async () => { | ||
await sendKeys({ press: 'Tab' }); | ||
expect(document.activeElement).to.equal(buttons[0]); | ||
|
||
await sendKeys({ press: 'ArrowRight' }); | ||
expect(document.activeElement).to.equal(buttons[1]); | ||
|
||
await sendKeys({ press: 'ArrowRight' }); | ||
expect(document.activeElement).to.equal(buttons[2]); | ||
|
||
await sendKeys({ press: 'ArrowLeft' }); | ||
expect(document.activeElement).to.equal(buttons[1]); | ||
|
||
await sendKeys({ press: 'ArrowLeft' }); | ||
expect(document.activeElement).to.equal(buttons[0]); | ||
}); | ||
|
||
it('should include disabled buttons in Tab navigation', async () => { | ||
menuBar.tabNavigation = true; | ||
|
||
await sendKeys({ press: 'Tab' }); | ||
expect(document.activeElement).to.equal(buttons[0]); | ||
|
||
await sendKeys({ press: 'Tab' }); | ||
expect(document.activeElement).to.equal(buttons[1]); | ||
|
||
await sendKeys({ press: 'Tab' }); | ||
expect(document.activeElement).to.equal(buttons[2]); | ||
|
||
await sendKeys({ down: 'Shift' }); | ||
await sendKeys({ press: 'Tab' }); | ||
await sendKeys({ up: 'Shift' }); | ||
expect(document.activeElement).to.equal(buttons[1]); | ||
|
||
await sendKeys({ down: 'Shift' }); | ||
await sendKeys({ press: 'Tab' }); | ||
await sendKeys({ up: 'Shift' }); | ||
expect(document.activeElement).to.equal(buttons[0]); | ||
}); | ||
}); |
Oops, something went wrong.