Skip to content

Commit 6ee246d

Browse files
Menu: dx-state-focused class should not be added if focusStateEnabled is set to false (T1306949) (#31060)
1 parent 7b6bbd3 commit 6ee246d

File tree

9 files changed

+148
-48
lines changed

9 files changed

+148
-48
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import type { KeyboardKeyDownEvent } from '@ts/events/core/m_keyboard_processor'
2727

2828
export const WIDGET_CLASS = 'dx-widget';
2929
const DISABLED_STATE_CLASS = 'dx-state-disabled';
30+
export const ACTIVE_STATE_CLASS = 'dx-state-active';
3031
export const FOCUSED_STATE_CLASS = 'dx-state-focused';
3132
export const HOVER_STATE_CLASS = 'dx-state-hover';
3233
const INVISIBLE_STATE_CLASS = 'dx-state-invisible';
@@ -527,7 +528,7 @@ class Widget<
527528
event?: DxEvent<PointerEvent | MouseEvent | TouchEvent>,
528529
): void {
529530
this.option('isActive', value);
530-
$element.toggleClass('dx-state-active', value);
531+
$element.toggleClass(ACTIVE_STATE_CLASS, value);
531532
}
532533

533534
_updatedHover(): void {

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,21 @@ import { getOuterHeight, getOuterWidth } from '@js/core/utils/size';
2626
import { findTemplates } from '@js/core/utils/template_manager';
2727
import { isDefined, isFunction, isPlainObject } from '@js/core/utils/type';
2828
import type { DataSourceOptions } from '@js/data/data_source';
29-
import DataHelperMixin from '@js/data_helper';
3029
import type {
3130
Cancelable, DxEvent,
3231
} from '@js/events';
33-
import type { CollectionWidgetItem as CollectionWidgetItemProperties, CollectionWidgetOptions, ItemLike } from '@js/ui/collection/ui.collection_widget.base';
32+
import type {
33+
CollectionWidgetItem as CollectionWidgetItemProperties,
34+
CollectionWidgetOptions,
35+
ItemLike,
36+
} from '@js/ui/collection/ui.collection_widget.base';
3437
import { getPublicElement } from '@ts/core/m_element';
3538
import { focusable } from '@ts/core/utils/m_selectors';
3639
import type { ActionConfig } from '@ts/core/widget/component';
3740
import type { OptionChanged } from '@ts/core/widget/types';
3841
import type { SupportedKeys, WidgetProperties } from '@ts/core/widget/widget';
3942
import Widget from '@ts/core/widget/widget';
43+
import DataHelperMixin from '@ts/data/m_data_helper';
4044
import type { ClickableCollectionWidgetItem, ItemClickEvent } from '@ts/ui/collection/item';
4145
import type CollectionItem from '@ts/ui/collection/item';
4246
import CollectionWidgetItem from '@ts/ui/collection/item';
@@ -563,7 +567,12 @@ class CollectionWidget<
563567
if ($target.length) {
564568
this._refreshActiveDescendant();
565569
this._refreshItemId($target, needCleanItemId);
566-
this._toggleFocusClass(isFocused, $target);
570+
571+
const { focusStateEnabled } = this.option();
572+
573+
if (focusStateEnabled) {
574+
this._toggleFocusClass(isFocused, $target);
575+
}
567576
}
568577

569578
this._updateParentActiveDescendant();

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

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

234234
this._$popup = $('<div>').appendTo(this.$element());
235-
const { rtlEnabled, container, animation } = this.option();
235+
const {
236+
rtlEnabled,
237+
container,
238+
animation,
239+
} = this.option();
236240

237241
this._popup = this._createComponent(this._$popup, Popup, {
238242
onInitialized(e) {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,10 @@ QUnit.module('functionality', moduleSetup, () => {
925925
});
926926

927927
QUnit.test('the selected item should be focused after popup is opened', function(assert) {
928+
if(shouldSkipOnMobile(assert)) {
929+
return;
930+
}
931+
928932
const items = [1, 2, 3];
929933
const item = items[1];
930934
const selectBox = $('#selectBox').dxSelectBox({
@@ -6062,6 +6066,10 @@ QUnit.module('focus policy', {
60626066
});
60636067

60646068
QUnit.test('selectbox should not focus disabled item after the search', function(assert) {
6069+
if(shouldSkipOnMobile(assert)) {
6070+
return;
6071+
}
6072+
60656073
this.instance.option({
60666074
searchEnabled: true,
60676075
opened: true,

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,6 +2451,10 @@ QUnit.module('keyboard navigation', {
24512451
}
24522452
}, () => {
24532453
QUnit.test('pagedown/pageup keys should move focus to last/first item', function(assert) {
2454+
if(shouldSkipOnMobile(assert)) {
2455+
return;
2456+
}
2457+
24542458
const $listItems = getListItems(this.instance);
24552459
this.keyboard.press('down');
24562460

@@ -2462,6 +2466,10 @@ QUnit.module('keyboard navigation', {
24622466
});
24632467

24642468
QUnit.test('down/up keys should move focus to next/previous item', function(assert) {
2469+
if(shouldSkipOnMobile(assert)) {
2470+
return;
2471+
}
2472+
24652473
const $listItems = getListItems(this.instance);
24662474
const $firstItem = $listItems.eq(0);
24672475
const $secondItem = $listItems.eq(1);
@@ -8365,6 +8373,10 @@ QUnit.module('valueChanged should receive correct event parameter', {
83658373

83668374
['enter', 'space'].forEach(key => {
83678375
QUnit.test(`on selectAll item selecting using ${key}`, function(assert) {
8376+
if(shouldSkipOnMobile(assert)) {
8377+
return;
8378+
}
8379+
83688380
this.keyboard
83698381
.focus()
83708382
.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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,10 @@ QUnit.module('Mentions module', moduleConfig, () => {
445445
});
446446

447447
test('list shouldn\'t be focused on text input', function(assert) {
448+
if(shouldSkipOnMobile(assert)) {
449+
return;
450+
}
451+
448452
const mention = new Mentions(this.quillMock, this.options);
449453

450454
mention.savePosition(0);
@@ -460,6 +464,10 @@ QUnit.module('Mentions module', moduleConfig, () => {
460464
});
461465

462466
test('trigger \'arrow down\' should focus next list item', function(assert) {
467+
if(shouldSkipOnMobile(assert)) {
468+
return;
469+
}
470+
463471
const mention = new Mentions(this.quillMock, this.options);
464472

465473
mention.savePosition(0);
@@ -522,6 +530,10 @@ QUnit.module('Mentions module', moduleConfig, () => {
522530
});
523531

524532
test('trigger \'arrow up\' should focus previous list item', function(assert) {
533+
if(shouldSkipOnMobile(assert)) {
534+
return;
535+
}
536+
525537
const mention = new Mentions(this.quillMock, this.options);
526538

527539
mention.savePosition(0);
@@ -540,6 +552,10 @@ QUnit.module('Mentions module', moduleConfig, () => {
540552
});
541553

542554
test('trigger "arrow down" or "arrow up" does not change focused item in case data source is loading', function(assert) {
555+
if(shouldSkipOnMobile(assert)) {
556+
return;
557+
}
558+
543559
const mention = new Mentions(this.quillMock, this.options);
544560

545561
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)