Skip to content

Commit e8c8f75

Browse files
authored
DateBox: timeview amPm popup should be inside dateBox popup content (T1300566) (#30450)
1 parent 8e6a969 commit e8c8f75

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
@@ -232,6 +232,9 @@ const TimeView = (Editor as any).inherit({
232232
time.setHours(newHours);
233233
this.option('value', time);
234234
},
235+
dropDownOptions: {
236+
container: this.$element(),
237+
},
235238
value: this._getValue().getHours() >= 12 ? TIMEVIEW_FORMAT12_PM : TIMEVIEW_FORMAT12_AM,
236239
stylingMode: this.option('stylingMode'),
237240
});

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
@@ -74,6 +74,7 @@ const CALENDAR_NAVIGATOR_PREVIOUS_VIEW_CLASS = 'dx-calendar-navigator-previous-v
7474
const DROPDOWNEDITOR_OVERLAY_CLASS = 'dx-dropdowneditor-overlay';
7575
const NUMBERBOX_CLASS = 'dx-numberbox';
7676
const NUMBERBOX_SPIN_DOWN_CLASS = 'dx-numberbox-spin-down';
77+
const SELECTBOX_CLASS = 'dx-selectbox';
7778
const SHOW_INVALID_BADGE_CLASS = 'dx-show-invalid-badge';
7879

7980
const APPLY_BUTTON_SELECTOR = '.dx-popup-done.dx-button';
@@ -3262,9 +3263,9 @@ QUnit.module('datebox with time component', {
32623263

32633264
dateBox.open();
32643265

3265-
const hourEditor = $('.dx-timeview-field .dx-numberbox').eq(0);
3266-
const minuteEditor = $('.dx-timeview-field .dx-numberbox').eq(1);
3267-
const amPmEditor = $('.dx-timeview-field .dx-selectbox').eq(0);
3266+
const hourEditor = $(`.${TIMEVIEW_CLASS} .${NUMBERBOX_CLASS}`).eq(0);
3267+
const minuteEditor = $(`.${TIMEVIEW_CLASS} .${NUMBERBOX_CLASS}`).eq(1);
3268+
const amPmEditor = $(`.${TIMEVIEW_CLASS} .${SELECTBOX_CLASS}`).eq(0);
32683269

32693270
assert.ok(hourEditor.hasClass('dx-editor-outlined'));
32703271
assert.ok(minuteEditor.hasClass('dx-editor-outlined'));
@@ -3284,15 +3285,32 @@ QUnit.module('datebox with time component', {
32843285

32853286
dateBox.open();
32863287

3287-
const hourEditor = $('.dx-timeview-field .dx-numberbox').eq(0);
3288-
const minuteEditor = $('.dx-timeview-field .dx-numberbox').eq(1);
3289-
const amPmEditor = $('.dx-timeview-field .dx-selectbox').eq(0);
3288+
const hourEditor = $(`.${TIMEVIEW_CLASS} .${NUMBERBOX_CLASS}`).eq(0);
3289+
const minuteEditor = $(`.${TIMEVIEW_CLASS} .${NUMBERBOX_CLASS}`).eq(1);
3290+
const amPmEditor = $(`.${TIMEVIEW_CLASS} .${SELECTBOX_CLASS}`).eq(0);
32903291

32913292
assert.ok(hourEditor.hasClass('dx-editor-underlined'));
32923293
assert.ok(minuteEditor.hasClass('dx-editor-underlined'));
32933294
assert.ok(amPmEditor.hasClass('dx-editor-underlined'));
32943295
});
32953296

3297+
QUnit.test('DateBox with timeview should have amPm popup inside of dateBox popup content (T1300566)', function(assert) {
3298+
const dateBox = $('#dateBox').dxDateBox({
3299+
type: 'datetime',
3300+
pickerType: 'calendar',
3301+
opened: true,
3302+
displayFormat: 'ddMMyy hh:mm',
3303+
}).dxDateBox('instance');
3304+
const amPmEditor = $(`.${TIMEVIEW_CLASS} .${SELECTBOX_CLASS}`).eq(0).dxSelectBox('instance');
3305+
3306+
amPmEditor.open();
3307+
3308+
const $dateBoxPopup = $(dateBox.content());
3309+
const $amPmPopup = $(amPmEditor.content());
3310+
3311+
assert.strictEqual($amPmPopup.closest($dateBoxPopup).length, 1, 'amPm popup is inside dateBox popup');
3312+
});
3313+
32963314
QUnit.test('Reset seconds and milliseconds when DateBox has no value for time view', function(assert) {
32973315
const dateBox = $('#dateBox').dxDateBox({
32983316
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)