Skip to content

Commit 25c11cb

Browse files
r-farkhutdinovRuslan Farkhutdinov
andauthored
DateBox: Fix floating label overlapping date format hint for native picker (T1328901) (#33707)
Co-authored-by: Ruslan Farkhutdinov <ruslan.farkhutdinov@devexpress.com>
1 parent a510fc8 commit 25c11cb

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,16 @@ class DateBox extends DropDownEditor<DateBoxBaseProperties> {
501501
return super._isClearButtonVisible() && !this._isNativeType();
502502
}
503503

504+
_toggleEmptinessEventHandler(): void {
505+
if (this._isNativeType()) {
506+
this._toggleEmptiness(false);
507+
508+
return;
509+
}
510+
511+
super._toggleEmptinessEventHandler();
512+
}
513+
504514
_renderValue(): DeferredObj<unknown> {
505515
const value = this.getDateOption('value');
506516

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ const CANCEL_BUTTON_SELECTOR = '.dx-popup-cancel.dx-button';
6262
const TODAY_BUTTON_SELECTOR = `.${TODAY_BUTTON_CLASS}.${BUTTON_CLASS}`;
6363
const BUTTON_SELECTOR = '.dx-button';
6464
const TEXTBOX_SELECTOR = '.dx-textbox';
65+
const TEXTEDITOR_EMPTY_INPUT_CLASS = 'dx-texteditor-empty';
66+
6567

6668
const widgetName = 'dxDateBox';
6769
const { module: testModule, test } = QUnit;
@@ -3059,6 +3061,25 @@ testModule('native picker', function() {
30593061
}
30603062
});
30613063
});
3064+
3065+
test('empty class should not be attached for native picker with null value (T1328901)', function(assert) {
3066+
const $dateBox = $('#dateBox').dxDateBox({
3067+
pickerType: 'native',
3068+
type: 'date',
3069+
value: null,
3070+
labelMode: 'floating',
3071+
label: 'Label',
3072+
});
3073+
const dateBox = $dateBox.dxDateBox('instance');
3074+
3075+
assert.strictEqual($dateBox.hasClass(TEXTEDITOR_EMPTY_INPUT_CLASS), false,
3076+
'empty class is not attached so floating label does not overlap with browser-rendered date format hint');
3077+
3078+
dateBox.option('value', new Date());
3079+
3080+
assert.strictEqual($dateBox.hasClass(TEXTEDITOR_EMPTY_INPUT_CLASS), false,
3081+
'empty class remains absent after value is set');
3082+
});
30623083
});
30633084

30643085
QUnit.module('valueChanged handler should receive correct event', {

0 commit comments

Comments
 (0)