-
Notifications
You must be signed in to change notification settings - Fork 671
Scheduler - A11y - remove tabindex attr from workspace and header #34205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bit-byte0
wants to merge
6
commits into
DevExpress:26_1
Choose a base branch
from
bit-byte0:fix/scheduler-a11y-remove-workspace-header-tabindex
base: 26_1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+240
−107
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bde3bc2
fix(scheduler): remove tabindex from header element
bit-byte0 9f026cb
fix(scheduler): remove workspace tabindex, rove focus to cells
bit-byte0 5d7adf5
fix(scheduler): change workspace tabindex to -1, revert cell focus ro…
bit-byte0 f6b0bff
test(scheduler): adapt keyboardMock and tab-order tests to workspace …
bit-byte0 b19af82
test(scheduler): adapt keyboardMock and tab-order tests to workspace …
bit-byte0 38b060a
test(scheduler): apply review fixes — dispose in header tests, strict…
bit-byte0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
59 changes: 59 additions & 0 deletions
59
packages/devextreme/js/__internal/scheduler/__tests__/header.test.ts
This file contains hidden or 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,59 @@ | ||
| import { | ||
| afterEach, beforeEach, describe, expect, it, | ||
| } from '@jest/globals'; | ||
| import $ from '@js/core/renderer'; | ||
|
|
||
| import { createScheduler } from './__mock__/create_scheduler'; | ||
| import { setupSchedulerTestEnvironment } from './__mock__/mock_scheduler'; | ||
|
|
||
| describe('Header', () => { | ||
| beforeEach(() => { | ||
| setupSchedulerTestEnvironment(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| const $scheduler = $(document.querySelector('.dx-scheduler')); | ||
| // @ts-expect-error | ||
| $scheduler.dxScheduler('dispose'); | ||
| document.body.innerHTML = ''; | ||
| }); | ||
|
|
||
| it('should not have tabIndex attr', async () => { | ||
| const { POM } = await createScheduler({ | ||
| dataSource: [], | ||
| currentView: 'day', | ||
| currentDate: new Date(2021, 4, 24), | ||
| }); | ||
|
|
||
| expect(POM.getHeader().hasAttribute('tabindex')).toBe(false); | ||
| }); | ||
|
|
||
| it('should not have tabIndex attr after tabIndex option change', async () => { | ||
| const { scheduler, POM } = await createScheduler({ | ||
| dataSource: [], | ||
| currentView: 'day', | ||
| currentDate: new Date(2021, 4, 24), | ||
| }); | ||
|
|
||
| scheduler.option('tabIndex', 1); | ||
|
|
||
| expect(POM.getHeader().hasAttribute('tabindex')).toBe(false); | ||
| }); | ||
|
|
||
| describe('Toolbar', () => { | ||
| it('should have viewSwitcher with locateInMenu: "auto" by default', async () => { | ||
| const { scheduler } = await createScheduler({ | ||
| dataSource: [], | ||
| currentView: 'day', | ||
| currentDate: new Date(2021, 4, 24), | ||
| }); | ||
|
|
||
| const toolbarItems = scheduler.option('toolbar.items') as any[]; | ||
| const viewSwitcherItem = toolbarItems.find((item: any) => item.name === 'viewSwitcher'); | ||
|
|
||
| expect(viewSwitcherItem).toBeDefined(); | ||
| expect(viewSwitcherItem.location).toBe('after'); | ||
| expect(viewSwitcherItem.locateInMenu).toBe('auto'); | ||
| }); | ||
| }); | ||
| }); |
24 changes: 0 additions & 24 deletions
24
packages/devextreme/js/__internal/scheduler/__tests__/toolbar_adaptivity.test.ts
This file was deleted.
Oops, something went wrong.
79 changes: 0 additions & 79 deletions
79
packages/devextreme/js/__internal/scheduler/__tests__/workspace.recalculation.test.ts
This file was deleted.
Oops, something went wrong.
153 changes: 153 additions & 0 deletions
153
packages/devextreme/js/__internal/scheduler/__tests__/workspace.test.ts
This file contains hidden or 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,153 @@ | ||
| import { | ||
| afterEach, beforeEach, describe, expect, it, | ||
| } from '@jest/globals'; | ||
| import $ from '@js/core/renderer'; | ||
| import { fireEvent } from '@testing-library/dom'; | ||
|
|
||
| import fx from '../../../common/core/animation/fx'; | ||
| import CustomStore from '../../../data/custom_store'; | ||
| import { createScheduler } from './__mock__/create_scheduler'; | ||
| import { setupSchedulerTestEnvironment } from './__mock__/mock_scheduler'; | ||
|
|
||
| const CLASSES = { | ||
| scheduler: 'dx-scheduler', | ||
| workSpace: 'dx-scheduler-work-space', | ||
| focusedState: 'dx-state-focused', | ||
| }; | ||
|
|
||
| const defaultOptions = { | ||
| currentView: 'week', | ||
| views: ['week'], | ||
| currentDate: new Date(2024, 0, 1), | ||
| startDayHour: 9, | ||
| endDayHour: 16, | ||
| height: 600, | ||
| }; | ||
|
|
||
| describe('Workspace', () => { | ||
| beforeEach(() => { | ||
| fx.off = true; | ||
| setupSchedulerTestEnvironment({ height: 600 }); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| const $scheduler = $(document.querySelector(`.${CLASSES.scheduler}`)); | ||
| // @ts-expect-error | ||
| $scheduler.dxScheduler('dispose'); | ||
| document.body.innerHTML = ''; | ||
| fx.off = false; | ||
| }); | ||
|
|
||
| it('should not duplicate workspace elements when resources are loaded asynchronously (T661335)', async () => { | ||
| const { scheduler, container } = await createScheduler({ | ||
| templatesRenderAsynchronously: true, | ||
| currentView: 'day', | ||
| views: ['day'], | ||
| groups: ['owner'], | ||
| resources: [ | ||
| { | ||
| fieldExpr: 'owner', | ||
| dataSource: [{ id: 1, text: 'Owner 1' }], | ||
| }, | ||
| { | ||
| fieldExpr: 'room', | ||
| dataSource: new CustomStore({ | ||
| load(): Promise<unknown> { | ||
| return new Promise((resolve) => { | ||
| setTimeout(() => { | ||
| resolve([{ id: 1, text: 'Room 1', color: '#ff0000' }]); | ||
| }); | ||
| }); | ||
| }, | ||
| }), | ||
| }, | ||
| ], | ||
| dataSource: [ | ||
| { | ||
| text: 'Meeting in Room 1', | ||
| startDate: new Date(2017, 4, 25, 9, 0), | ||
| endDate: new Date(2017, 4, 25, 10, 0), | ||
| roomId: 1, | ||
| }, | ||
| ], | ||
| startDayHour: 9, | ||
| currentDate: new Date(2017, 4, 25), | ||
| height: 600, | ||
| }); | ||
|
|
||
| scheduler.option('groups', ['room']); | ||
|
|
||
| await new Promise((r) => { setTimeout(r); }); | ||
|
|
||
| const $workSpaces = $(container).find(`.${CLASSES.workSpace}`); | ||
| const $groupHeader = $(container).find('.dx-scheduler-group-header'); | ||
|
|
||
| expect($workSpaces.length).toBe(1); | ||
|
|
||
| expect($groupHeader.length).toBeGreaterThan(0); | ||
| expect($groupHeader.text()).toContain('Room 1'); | ||
| }); | ||
|
|
||
| describe('A11y', () => { | ||
| it('should have tabIndex -1 to be skipped in the tab order', async () => { | ||
| const { POM } = await createScheduler(defaultOptions); | ||
|
|
||
| expect(POM.getWorkSpace().getAttribute('tabindex')).toBe('-1'); | ||
| }); | ||
|
|
||
| it('should have tabIndex -1 after tabIndex option change', async () => { | ||
| const { scheduler, POM } = await createScheduler(defaultOptions); | ||
|
|
||
| scheduler.option('tabIndex', 1); | ||
|
|
||
| expect(POM.getWorkSpace().getAttribute('tabindex')).toBe('-1'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Keyboard navigation', () => { | ||
| it('should focus the clicked cell', async () => { | ||
| const { POM } = await createScheduler(defaultOptions); | ||
|
|
||
| const cell = POM.getDateTableCell(0, 0); | ||
| fireEvent.mouseDown(cell, { which: 1 }); | ||
| fireEvent.mouseUp(cell); | ||
|
|
||
| expect(cell.classList.contains(CLASSES.focusedState)).toBe(true); | ||
| }); | ||
|
|
||
| it('should move focus and selection to the next cell on arrow key', async () => { | ||
| const { POM } = await createScheduler(defaultOptions); | ||
|
|
||
| const firstCell = POM.getDateTableCell(0, 0); | ||
| const secondCell = POM.getDateTableCell(1, 0); | ||
| fireEvent.mouseDown(firstCell, { which: 1 }); | ||
| fireEvent.mouseUp(firstCell); | ||
| fireEvent.keyDown(POM.getWorkSpace(), { key: 'ArrowDown' }); | ||
|
|
||
| expect(secondCell.classList.contains(CLASSES.focusedState)).toBe(true); | ||
| expect(firstCell.classList.contains(CLASSES.focusedState)).toBe(false); | ||
| }); | ||
|
|
||
| it('should extend selection on shift + arrow key', async () => { | ||
| const { scheduler, POM } = await createScheduler(defaultOptions); | ||
|
|
||
| const firstCell = POM.getDateTableCell(0, 0); | ||
| fireEvent.mouseDown(firstCell, { which: 1 }); | ||
| fireEvent.mouseUp(firstCell); | ||
| fireEvent.keyDown(POM.getWorkSpace(), { key: 'ArrowDown', shiftKey: true }); | ||
|
|
||
| expect(scheduler.option('selectedCellData')).toHaveLength(2); | ||
| }); | ||
|
|
||
| it('should clear focused cell when focus leaves the workspace', async () => { | ||
| const { POM } = await createScheduler(defaultOptions); | ||
|
|
||
| const cell = POM.getDateTableCell(0, 0); | ||
| fireEvent.mouseDown(cell, { which: 1 }); | ||
| fireEvent.mouseUp(cell); | ||
| fireEvent.focusOut(POM.getWorkSpace()); | ||
|
|
||
| expect(cell.classList.contains(CLASSES.focusedState)).toBe(false); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.