Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { fitIntoRange, inRange, sign } from '@js/core/utils/math';
import {
isDate, isDefined, isFunction, isString,
} from '@js/core/utils/type';
import type { DxEvent } from '@js/events';
import type { Properties } from '@js/ui/date_box';
import dateLocalization from '@ts/core/localization/date';

Expand Down Expand Up @@ -661,18 +662,22 @@ class DateBoxMask extends DateBoxBase {
}
}

_enterHandler() {
_enterHandler(): void {
this._fireChangeEvent();
this._selectNextPart(FORWARD);

if (this._useMaskBehavior() && this._isAllSelected()) {
this._selectFirstPart();
} else {
this._selectNextPart(FORWARD);
}
}

_focusOutHandler(e) {
_focusOutHandler(e: DxEvent): void {
const shouldFireChangeEvent = this._useMaskBehavior() && !e.isDefaultPrevented();

if (shouldFireChangeEvent) {
this._fireChangeEvent();
super._focusOutHandler(e);
this._selectFirstPart();
} else {
super._focusOutHandler(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1866,6 +1866,24 @@ module('Caret moving', setupModule, () => {

assert.deepEqual(this.keyboard.caret(), allSelectedCaret, 'no date part is selected');
});

test('should keep active part after focus out and focus in (T1318439)', function(assert) {
const caretYear = { start: 11, end: 15 };

this.instance.option({
useMaskBehavior: true,
mode: 'text',
});

this.keyboard.press('end');

assert.deepEqual(this.keyboard.caret(), caretYear, 'year is selected initially');

this.$input.trigger('focusout');
this.$input.trigger('focusin');

assert.deepEqual(this.keyboard.caret(), caretYear, 'year is selected after focus return');
});
});

module('Using beforeInput event', {
Expand Down
Loading