Skip to content

Commit c960fd0

Browse files
Menu: dx-state-focused class should not be added if focusStateEnabled… (#31495)
Co-authored-by: EugeniyKiyashko <[email protected]>
1 parent 6cea514 commit c960fd0

File tree

9 files changed

+152
-47
lines changed

9 files changed

+152
-47
lines changed

packages/devextreme/js/__internal/core/widget/widget.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import DOMComponent from './dom_component';
2424
import type { OptionChanged } from './types';
2525

2626
const DISABLED_STATE_CLASS = 'dx-state-disabled';
27+
export const ACTIVE_STATE_CLASS = 'dx-state-active';
2728
export const FOCUSED_STATE_CLASS = 'dx-state-focused';
2829
const INVISIBLE_STATE_CLASS = 'dx-state-invisible';
2930

@@ -502,7 +503,7 @@ class Widget<
502503
event?: Record<string, unknown>,
503504
): void {
504505
this.option('isActive', value);
505-
$element.toggleClass('dx-state-active', value);
506+
$element.toggleClass(ACTIVE_STATE_CLASS, value);
506507
}
507508

508509
_updatedHover(): void {

packages/devextreme/js/__internal/ui/collection/collection_widget.base.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ import DataHelperMixin from '@js/data_helper';
3333
import type {
3434
Cancelable, DxEvent, EventInfo, ItemInfo,
3535
} from '@js/events';
36-
import type { CollectionWidgetItem as CollectionWidgetItemProperties, CollectionWidgetOptions, ItemLike } from '@js/ui/collection/ui.collection_widget.base';
36+
import type {
37+
CollectionWidgetItem as CollectionWidgetItemProperties,
38+
CollectionWidgetOptions,
39+
ItemLike,
40+
} from '@js/ui/collection/ui.collection_widget.base';
3741
import { focusable } from '@js/ui/widget/selectors';
3842
import { getPublicElement } from '@ts/core/m_element';
3943
import type { ActionConfig } from '@ts/core/widget/component';
@@ -531,7 +535,12 @@ class CollectionWidget<
531535
if ($target.length) {
532536
this._refreshActiveDescendant();
533537
this._refreshItemId($target, needCleanItemId);
534-
this._toggleFocusClass(isFocused, $target);
538+
539+
const { focusStateEnabled } = this.option();
540+
541+
if (focusStateEnabled) {
542+
this._toggleFocusClass(isFocused, $target);
543+
}
535544
}
536545

537546
this._updateParentActiveDescendant();

packages/devextreme/js/__internal/ui/toolbar/internal/m_toolbar.menu.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,11 @@ export default class DropDownMenu extends Widget<DropDownMenuProperties> {
228228
}
229229

230230
this._$popup = $('<div>').appendTo(this.$element());
231-
const { rtlEnabled, container, animation } = this.option();
231+
const {
232+
rtlEnabled,
233+
container,
234+
animation,
235+
} = this.option();
232236

233237
this._popup = this._createComponent(this._$popup, 'dxPopup', {
234238
onInitialized({ component }) {

packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/selectBox.tests.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import ariaAccessibilityTestHelper from '../../helpers/ariaAccessibilityTestHelp
1515
import { normalizeKeyName } from 'common/core/events/utils/index';
1616
import messageLocalization from 'common/core/localization/message';
1717

18+
import { shouldSkipOnMobile } from '../../helpers/device.js';
19+
1820
import 'generic_light.css!';
1921
import 'ui/validator';
2022

@@ -932,6 +934,10 @@ QUnit.module('functionality', moduleSetup, () => {
932934
});
933935

934936
QUnit.test('the selected item should be focused after popup is opened', function(assert) {
937+
if(shouldSkipOnMobile(assert)) {
938+
return;
939+
}
940+
935941
const items = [1, 2, 3];
936942
const item = items[1];
937943
const selectBox = $('#selectBox').dxSelectBox({
@@ -6086,6 +6092,10 @@ QUnit.module('focus policy', {
60866092
});
60876093

60886094
QUnit.test('selectbox should not focus disabled item after the search', function(assert) {
6095+
if(shouldSkipOnMobile(assert)) {
6096+
return;
6097+
}
6098+
60896099
this.instance.option({
60906100
searchEnabled: true,
60916101
opened: true,

packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/tagBox.tests.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import Guid from 'core/guid';
2323
import browser from 'core/utils/browser';
2424

2525
import { TextEditorLabel } from '__internal/ui/text_box/m_text_editor.label';
26+
import { shouldSkipOnMobile } from '../../helpers/device.js';
2627

2728
import 'generic_light.css!';
2829

@@ -2450,6 +2451,10 @@ QUnit.module('keyboard navigation', {
24502451
}
24512452
}, () => {
24522453
QUnit.test('pagedown/pageup keys should move focus to last/first item', function(assert) {
2454+
if(shouldSkipOnMobile(assert)) {
2455+
return;
2456+
}
2457+
24532458
const $listItems = getListItems(this.instance);
24542459
this.keyboard.press('down');
24552460

@@ -2461,6 +2466,10 @@ QUnit.module('keyboard navigation', {
24612466
});
24622467

24632468
QUnit.test('down/up keys should move focus to next/previous item', function(assert) {
2469+
if(shouldSkipOnMobile(assert)) {
2470+
return;
2471+
}
2472+
24642473
const $listItems = getListItems(this.instance);
24652474
const $firstItem = $listItems.eq(0);
24662475
const $secondItem = $listItems.eq(1);
@@ -8386,6 +8395,10 @@ QUnit.module('valueChanged should receive correct event parameter', {
83868395

83878396
['enter', 'space'].forEach(key => {
83888397
QUnit.test(`on selectAll item selecting using ${key}`, function(assert) {
8398+
if(shouldSkipOnMobile(assert)) {
8399+
return;
8400+
}
8401+
83898402
this.keyboard
83908403
.focus()
83918404
.press('down')

packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/mentionIntegration.tests.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'ui/html_editor';
44

55
import nativePointerMock from '../../../helpers/nativePointerMock.js';
66
import { prepareEmbedValue } from './utils.js';
7+
import { shouldSkipOnMobile } from '../../../helpers/device.js';
78

89
const { test, module } = QUnit;
910

@@ -384,6 +385,10 @@ export default function() {
384385
});
385386

386387
test('first list item should be focused on filtering', function(assert) {
388+
if(shouldSkipOnMobile(assert)) {
389+
return;
390+
}
391+
387392
const done = assert.async();
388393
const valueChangeSpy = sinon.spy(() => {
389394
if(valueChangeSpy.calledOnce) {
@@ -644,6 +649,10 @@ export default function() {
644649
});
645650

646651
test('aria-activedescendant should only exist on textbox when mention pops up', function(assert) {
652+
if(shouldSkipOnMobile(assert)) {
653+
return;
654+
}
655+
647656
const done = assert.async();
648657
const valueChangeSpy = sinon.spy(() => {
649658
if(valueChangeSpy.calledOnce) {

packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/mentionModule.tests.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { Event as dxEvent } from 'common/core/events';
99
import { normalizeKeyName } from 'common/core/events/utils/index';
1010
import Quill from 'devextreme-quill';
1111

12+
import { shouldSkipOnMobile } from '../../../helpers/device.js';
13+
1214
const SUGGESTION_LIST_CLASS = 'dx-suggestion-list';
1315
const LIST_ITEM_CLASS = 'dx-list-item';
1416
const FOCUSED_STATE_CLASS = 'dx-state-focused';
@@ -445,6 +447,10 @@ QUnit.module('Mentions module', moduleConfig, () => {
445447
});
446448

447449
test('list shouldn\'t be focused on text input', function(assert) {
450+
if(shouldSkipOnMobile(assert)) {
451+
return;
452+
}
453+
448454
const mention = new Mentions(this.quillMock, this.options);
449455

450456
mention.savePosition(0);
@@ -460,6 +466,10 @@ QUnit.module('Mentions module', moduleConfig, () => {
460466
});
461467

462468
test('trigger \'arrow down\' should focus next list item', function(assert) {
469+
if(shouldSkipOnMobile(assert)) {
470+
return;
471+
}
472+
463473
const mention = new Mentions(this.quillMock, this.options);
464474

465475
mention.savePosition(0);
@@ -523,6 +533,10 @@ QUnit.module('Mentions module', moduleConfig, () => {
523533
});
524534

525535
test('trigger \'arrow up\' should focus previous list item', function(assert) {
536+
if(shouldSkipOnMobile(assert)) {
537+
return;
538+
}
539+
526540
const mention = new Mentions(this.quillMock, this.options);
527541

528542
mention.savePosition(0);
@@ -541,6 +555,10 @@ QUnit.module('Mentions module', moduleConfig, () => {
541555
});
542556

543557
test('trigger "arrow down" or "arrow up" does not change focused item in case data source is loading', function(assert) {
558+
if(shouldSkipOnMobile(assert)) {
559+
return;
560+
}
561+
544562
const mention = new Mentions(this.quillMock, this.options);
545563

546564
mention.savePosition(0);

packages/devextreme/testing/tests/DevExpress.ui.widgets/toolbar.menu.tests.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -578,21 +578,20 @@ QUnit.module('widget sizing render', moduleConfig, () => {
578578
});
579579

580580
QUnit.test('navigation by arrows', function(assert) {
581-
assert.expect(4);
582-
583581
this.instance.option('opened', false);
584582
this.overflowMenu.$button().focusin();
585583

586584
this.keyboard.keyDown('enter');
587585
assert.ok(this.overflowMenu.popup().option('visible'));
586+
588587
this.keyboard.keyDown('down');
589-
assert.ok(this.overflowMenu.$items().eq(0).hasClass(STATE_FOCUSED_CLASS), 'first item has focus class');
588+
assert.ok(this.overflowMenu.$items().attr('id'), 'first item is active');
590589

591590
this.keyboard.keyDown('down');
592-
assert.ok(this.overflowMenu.$items().eq(1).hasClass(STATE_FOCUSED_CLASS), 'second item has focus class');
591+
assert.ok(this.overflowMenu.$items().eq(1).attr('id'), 'second item is active');
593592

594593
this.keyboard.keyDown('up');
595-
assert.ok(this.overflowMenu.$items().eq(0).hasClass(STATE_FOCUSED_CLASS), 'first item has focus class');
594+
assert.ok(this.overflowMenu.$items().eq(0).attr('id'), 'third item is active');
596595
});
597596

598597
QUnit.test('hide popup on press tab', function(assert) {

0 commit comments

Comments
 (0)