Skip to content

Commit dfc2763

Browse files
authored
DateBox: timeview amPm popup should be inside dateBox popup content (T1300566)
1 parent 0f9eab9 commit dfc2763

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

packages/devextreme/js/__internal/ui/date_box/m_time_view.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ class TimeView extends Editor<TimeViewProperties> {
269269
time.setHours(newHours);
270270
this.option('value', time);
271271
},
272+
dropDownOptions: {
273+
container: this.$element(),
274+
},
272275
value: this._getValue().getHours() >= 12 ? TIMEVIEW_FORMAT12_PM : TIMEVIEW_FORMAT12_AM,
273276
stylingMode: this.option('stylingMode'),
274277
},

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

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const CALENDAR_NAVIGATOR_PREVIOUS_VIEW_CLASS = 'dx-calendar-navigator-previous-v
7575
const DROPDOWNEDITOR_OVERLAY_CLASS = 'dx-dropdowneditor-overlay';
7676
const NUMBERBOX_CLASS = 'dx-numberbox';
7777
const NUMBERBOX_SPIN_DOWN_CLASS = 'dx-numberbox-spin-down';
78+
const SELECTBOX_CLASS = 'dx-selectbox';
7879
const SHOW_INVALID_BADGE_CLASS = 'dx-show-invalid-badge';
7980

8081
const APPLY_BUTTON_SELECTOR = '.dx-popup-done.dx-button';
@@ -3250,9 +3251,9 @@ QUnit.module('datebox with time component', {
32503251

32513252
dateBox.open();
32523253

3253-
const hourEditor = $('.dx-timeview-field .dx-numberbox').eq(0);
3254-
const minuteEditor = $('.dx-timeview-field .dx-numberbox').eq(1);
3255-
const amPmEditor = $('.dx-timeview-field .dx-selectbox').eq(0);
3254+
const hourEditor = $(`.${TIMEVIEW_CLASS} .${NUMBERBOX_CLASS}`).eq(0);
3255+
const minuteEditor = $(`.${TIMEVIEW_CLASS} .${NUMBERBOX_CLASS}`).eq(1);
3256+
const amPmEditor = $(`.${TIMEVIEW_CLASS} .${SELECTBOX_CLASS}`).eq(0);
32563257

32573258
assert.ok(hourEditor.hasClass('dx-editor-outlined'));
32583259
assert.ok(minuteEditor.hasClass('dx-editor-outlined'));
@@ -3271,15 +3272,32 @@ QUnit.module('datebox with time component', {
32713272

32723273
dateBox.open();
32733274

3274-
const hourEditor = $('.dx-timeview-field .dx-numberbox').eq(0);
3275-
const minuteEditor = $('.dx-timeview-field .dx-numberbox').eq(1);
3276-
const amPmEditor = $('.dx-timeview-field .dx-selectbox').eq(0);
3275+
const hourEditor = $(`.${TIMEVIEW_CLASS} .${NUMBERBOX_CLASS}`).eq(0);
3276+
const minuteEditor = $(`.${TIMEVIEW_CLASS} .${NUMBERBOX_CLASS}`).eq(1);
3277+
const amPmEditor = $(`.${TIMEVIEW_CLASS} .${SELECTBOX_CLASS}`).eq(0);
32773278

32783279
assert.ok(hourEditor.hasClass('dx-editor-underlined'));
32793280
assert.ok(minuteEditor.hasClass('dx-editor-underlined'));
32803281
assert.ok(amPmEditor.hasClass('dx-editor-underlined'));
32813282
});
32823283

3284+
QUnit.test('DateBox with timeview should have amPm popup inside of dateBox popup content (T1300566)', function(assert) {
3285+
const dateBox = $('#dateBox').dxDateBox({
3286+
type: 'datetime',
3287+
pickerType: 'calendar',
3288+
opened: true,
3289+
displayFormat: 'ddMMyy hh:mm',
3290+
}).dxDateBox('instance');
3291+
const amPmEditor = $(`.${TIMEVIEW_CLASS} .${SELECTBOX_CLASS}`).eq(0).dxSelectBox('instance');
3292+
3293+
amPmEditor.open();
3294+
3295+
const $dateBoxPopup = $(dateBox.content());
3296+
const $amPmPopup = $(amPmEditor.content());
3297+
3298+
assert.strictEqual($amPmPopup.closest($dateBoxPopup).length, 1, 'amPm popup is inside dateBox popup');
3299+
});
3300+
32833301
QUnit.test('Reset seconds and milliseconds when DateBox has no value for time view', function(assert) {
32843302
const dateBox = $('#dateBox').dxDateBox({
32853303
pickerType: 'list',

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,16 @@ QUnit.module('12 hours format', () => {
332332
assert.equal($element.find('.' + TIMEVIEW_FORMAT12_CLASS).length, 0, 'input was removed');
333333
});
334334

335+
QUnit.test('format selectBox should set timeView root as a dropDown container (T1300566)', function(assert) {
336+
const $element = $('#timeView').dxTimeView({
337+
use24HourFormat: false,
338+
});
339+
const formatSelectBox = $element.find(`.${TIMEVIEW_FORMAT12_CLASS}`).dxSelectBox('instance');
340+
const $container = formatSelectBox.option('dropDownOptions.container');
341+
342+
assert.strictEqual($container.is($element), true);
343+
});
344+
335345
QUnit.test('timeView should use localized message for the 24hour format selectBox', function(assert) {
336346
const getPeriodNames = sinon.stub(dateLocalization, 'getPeriodNames').returns(['A', 'P']);
337347

0 commit comments

Comments
 (0)