Skip to content

Commit 7ff17c5

Browse files
authored
Scheduler: keyboard navigation through appointments on mac (#29719) (#29724)
1 parent 39ba5c7 commit 7ff17c5

File tree

2 files changed

+80
-0
lines changed
  • e2e/testcafe-devextreme/tests/scheduler/common/keyboardNavigation
  • packages/devextreme/js/__internal/scheduler/workspaces

2 files changed

+80
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import Scheduler from 'devextreme-testcafe-models/scheduler';
2+
import { ClientFunction, Selector } from 'testcafe';
3+
import url from '../../../../helpers/getPageUrl';
4+
import { createWidget } from '../../../../helpers/createWidget';
5+
import { appendElementTo } from '../../../../helpers/domUtils';
6+
7+
fixture.disablePageReloads`KeyboardNavigation.DateTable`
8+
.page(url(__dirname, '../../../container.html'));
9+
10+
const PARENT_SELECTOR = '#parentContainer';
11+
const SCHEDULER_SELECTOR = '#container';
12+
const BOTTOM_BTN_ID = 'bottom-btn';
13+
const BOTTOM_BTN_SELECTOR = `#${BOTTOM_BTN_ID}`;
14+
15+
const setMacOsScrollableOptions = ClientFunction(() => {
16+
($(SCHEDULER_SELECTOR) as any)
17+
.dxScheduler('instance')
18+
.getWorkSpaceScrollable()
19+
.option('useNative', true);
20+
}, { dependencies: { SCHEDULER_SELECTOR } });
21+
22+
[
23+
'day',
24+
'week',
25+
].forEach((currentView) => {
26+
test(`Should pass focus to the next elements after date table on Mac devices (view: ${currentView})`, async (t) => {
27+
const bottomBtn = Selector(BOTTOM_BTN_SELECTOR);
28+
const scheduler = new Scheduler(SCHEDULER_SELECTOR);
29+
const usualAppointment = scheduler.getAppointment('Usual');
30+
31+
await t
32+
.click(usualAppointment.element)
33+
.pressKey('tab tab');
34+
35+
await t.expect(bottomBtn.focused).ok();
36+
}).before(async () => {
37+
await appendElementTo(PARENT_SELECTOR, 'button', BOTTOM_BTN_ID);
38+
await createWidget('dxScheduler', {
39+
dataSource: [
40+
{
41+
startDate: '2024-01-01T01:00:00',
42+
endDate: '2024-01-01T02:00:00',
43+
text: 'Usual',
44+
},
45+
// NOTE: This case is reproduced only if view has allDay appointment
46+
{
47+
startDate: '2024-01-01T01:00:00',
48+
endDate: '2024-01-01T02:00:00',
49+
text: 'All-day',
50+
allDay: true,
51+
},
52+
],
53+
// NOTE: Scheduler should have a height limit for enabling native scroll container
54+
height: 300,
55+
currentDate: '2024-01-01',
56+
currentView,
57+
});
58+
await setMacOsScrollableOptions();
59+
});
60+
});

packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,30 @@ class SchedulerWorkSpace extends WidgetObserver {
605605
onScroll: () => {
606606
this._groupedStrategy.cache?.clear();
607607
},
608+
// TODO (Scrollable:useKeyboard) -> remove this WA
609+
// after ScrollView private option "useKeyboard" will be extended to useNative: true
610+
// NOTE: Scrollable container focusable by default
611+
// To prevent scroll container focus in native mode we set tabindex -1 to container
612+
// In simulated mode focusable behavior prevented by useKeyboard: false private option
613+
onInitialized: ({ component }) => {
614+
const useKeyboardDisabled = component.option('useKeyboard') === false;
615+
const useNativeEnabled = component.option('useNative') === true;
616+
if (useKeyboardDisabled && useNativeEnabled) {
617+
$(component.container()).attr('tabindex', -1);
618+
}
619+
},
620+
onOptionChanged: ({ fullName, value, component }) => {
621+
const useKeyboardDisabled = component.option('useKeyboard') === false;
622+
if (useKeyboardDisabled && fullName === 'useNative' && value === true) {
623+
$(component.container()).attr('tabindex', -1);
624+
}
625+
},
608626
};
627+
609628
if (this._needCreateCrossScrolling()) {
610629
config = extend(config, this._createCrossScrollingConfig(config));
611630
}
631+
612632
if (this.isVirtualScrolling()
613633
&& (this.virtualScrollingDispatcher.horizontalScrollingAllowed
614634
|| this.virtualScrollingDispatcher.height)) {

0 commit comments

Comments
 (0)