Skip to content

Commit 5ff2b80

Browse files
NumberBox: Fix tabIndex attribute not set on init (T1275314) (DevExpress#29083)
1 parent 068a1c3 commit 5ff2b80

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

packages/devextreme/js/__internal/ui/number_box/m_number_box.base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ const NumberBoxBase = TextEditor.inherit({
109109
this.$element().addClass(WIDGET_CLASS);
110110

111111
this.callBase();
112+
this._toggleTabIndex();
112113
},
113114

114115
_getDefaultAttributes() {

packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/numberBoxParts/common.tests.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,27 @@ QUnit.module('basics', {}, () => {
6767
assert.equal($element.find('.' + INPUT_CLASS).attr('inputmode'), 'decimal', 'inputmode is correct');
6868
});
6969

70+
QUnit.module('Tabindex', () => {
71+
[false, true].forEach((initialFocusStateEnabled) => {
72+
QUnit.test(`should be ${initialFocusStateEnabled ? 0 : -1} if focusStateEnabled = ${initialFocusStateEnabled} on init (T1275314)`, function(assert) {
73+
const $element = $('#numberbox').dxNumberBox({ focusStateEnabled: initialFocusStateEnabled });
74+
const $input = $element.find(`.${INPUT_CLASS}`);
75+
76+
assert.strictEqual($input.prop('tabindex'), initialFocusStateEnabled ? 0 : -1);
77+
});
78+
79+
QUnit.test(`should be updated when focusStateEnabled changes from ${initialFocusStateEnabled} to ${!initialFocusStateEnabled}`, function(assert) {
80+
const $element = $('#numberbox').dxNumberBox({ focusStateEnabled: initialFocusStateEnabled });
81+
const instance = $element.dxNumberBox('instance');
82+
const $input = $element.find(`.${INPUT_CLASS}`);
83+
84+
instance.option('focusStateEnabled', !initialFocusStateEnabled);
85+
86+
assert.strictEqual($input.prop('tabindex'), initialFocusStateEnabled ? -1 : 0, 'Updated tabindex is correct');
87+
});
88+
});
89+
});
90+
7091
QUnit.test('onContentReady fired after the widget is fully ready', function(assert) {
7192
assert.expect(2);
7293

0 commit comments

Comments
 (0)