Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateBox: fix formatting of min/max attribute in datetime picker type (T1252602) #28647

Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -67,9 +67,12 @@ const NativeStrategy = DateBoxStrategy.inherit({
},

renderInputMinMax($input) {
const type = this.dateBox.option('type');
const format = type === 'datetime' ? 'yyyy-MM-ddTHH:mm' : 'yyyy-MM-dd';
nikkithelegendarypokemonster marked this conversation as resolved.
Show resolved Hide resolved

$input.attr({
min: dateSerialization.serializeDate(this.dateBox.dateOption('min'), 'yyyy-MM-dd'),
max: dateSerialization.serializeDate(this.dateBox.dateOption('max'), 'yyyy-MM-dd'),
min: dateSerialization.serializeDate(this.dateBox.dateOption('min'), format),
max: dateSerialization.serializeDate(this.dateBox.dateOption('max'), format),
});
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,21 @@ QUnit.module('datebox tests', moduleConfig, () => {
assert.equal($dropDownButton.length, expectedButtonsNumber, 'correct readOnly value');
});

QUnit.test('Datebox should set min/max attributes to datetime input in localized datetime format (T1252602)', function(assert) {
const $dateBox = $('#dateBox').dxDateBox({
type: 'datetime',
pickerType: 'native',
value: new Date(),
nikkithelegendarypokemonster marked this conversation as resolved.
Show resolved Hide resolved
inputAttr: { 'aria-label': 'Date Time' },
nikkithelegendarypokemonster marked this conversation as resolved.
Show resolved Hide resolved
min: new Date(2024, 8, 10, 16, 54, 10),
max: new Date(2024, 8, 27, 16, 54, 10)
});

const $input = $dateBox.find('.' + TEXTEDITOR_INPUT_CLASS);
nikkithelegendarypokemonster marked this conversation as resolved.
Show resolved Hide resolved
assert.equal($input.attr('min'), '2024-09-10T16:54', 'minimum date changed correctly');
nikkithelegendarypokemonster marked this conversation as resolved.
Show resolved Hide resolved
assert.equal($input.attr('max'), '2024-09-27T16:54', 'maximum date changed correctly');
});

QUnit.test('Datebox should set min and max attributes to the native input (T258860) after option changed', function(assert) {
const $dateBox = $('#dateBox').dxDateBox({
type: 'date',
Expand Down
Loading