Skip to content

Commit

Permalink
DateBox: Rearrange attaching mouseEvents before rendering masks (DevE…
Browse files Browse the repository at this point in the history
…xpress#27418)

Co-authored-by: EugeniyKiyashko <[email protected]>
  • Loading branch information
1 parent 47be0cb commit 4f8b6b5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/devextreme/js/ui/text_box/ui.text_editor.mask.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ const TextEditorMask = TextEditorBase.inherit({
},

_render() {
this._attachMouseWheelEventHandlers();
this._renderMask();
this.callBase();
this._attachDropEventHandler();
this._attachMouseWheelEventHandlers();
},

_renderHiddenElement: function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2082,6 +2082,46 @@ QUnit.module('datebox and calendar integration', () => {
instance.option('calendarOptions.visible', true);
assert.strictEqual($(instance.content()).parent().find('.dx-button-today').length, 1);
});

QUnit.test('change year via scroll should log proper year in on value change event (T1229926)', function(assert) {
if(devices.real().deviceType !== 'desktop') {
assert.ok(true, 'device is not desktop');
return;
}

const valueChangedHandle = sinon.spy();
const date = new Date();
const currentYear = date.getFullYear();
const datebox = $('#dateBox').dxDateBox({
type: 'date',
value: date,
displayFormat: 'M/dd/yyyy',
valueChangeEvent: 'dxmousewheel',
useMaskBehavior: true,
onValueChanged: valueChangedHandle
}).dxDateBox('instance');

const $input = $(datebox.element()).find(`.${TEXTEDITOR_INPUT_CLASS}`);
const pointer = pointerMock($input);
const keyboard = keyboardMock($input, true);

keyboard.caret({ start: 12, end: 15 });

$input.trigger('dxclick');

pointer.wheel(1);

let changedValue = valueChangedHandle.getCall(0).args[0];
assert.strictEqual(valueChangedHandle.callCount, 1, 'handler has been called once');
assert.deepEqual(new Date(changedValue.value).getFullYear(), currentYear + 1, 'value year is correct'); assert.deepEqual(new Date(changedValue.previousValue).getFullYear(), currentYear, 'previous value year is correct');

pointer.wheel(1);

changedValue = valueChangedHandle.getCall(1).args[0];
assert.strictEqual(valueChangedHandle.callCount, 2, 'handler has been called twice');
assert.deepEqual(new Date(changedValue.value).getFullYear(), currentYear + 2, 'value year is correct');
assert.deepEqual(new Date(changedValue.previousValue).getFullYear(), currentYear + 1, 'previous value year is correct');
});
});

QUnit.module('datebox w/ calendar', {
Expand Down

0 comments on commit 4f8b6b5

Please sign in to comment.