Skip to content
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
8 changes: 5 additions & 3 deletions packages/devextreme/js/__internal/ui/color_box/color_box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,11 @@ class ColorBox extends DropDownEditor<ColorBoxProperties> {

_updateColorViewValue(value: string | null | undefined): void {
if (this._colorView) {
const colorViewValue = value === '' ? null : value;

this._colorView.option({
value,
matchValue: value,
value: colorViewValue,
matchValue: colorViewValue,
});
}
}
Expand Down Expand Up @@ -414,7 +416,7 @@ class ColorBox extends DropDownEditor<ColorBoxProperties> {
_valueOptionChangeHandler(): void {
const { value } = this.option();

if (value === null) {
if (!value) {
this._shouldSaveEmptyValue = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,31 @@ QUnit.module('Regressions', {
assert.equal(colorBox.option('value'), null);
assert.equal(colorBox.option('text'), '');
});

[false, true].forEach(editAlphaChannel => {
QUnit.test(`value should be cleared by backspace after color selecting if applyValueMode = instantly, editAlphaChannel = ${editAlphaChannel} (T1336404)`, function(assert) {
const $colorBox = $('#color-box').dxColorBox({
value: '#f05b41',
applyValueMode: 'instantly',
editAlphaChannel,
opened: true,
});
const colorBox = $colorBox.dxColorBox('instance');
const $input = $colorBox.find(`.${COLOR_BOX_INPUT_CLASS}`);
const keyboard = keyboardMock($input);

keyboard.press('up');

keyboard
.caret({ start: 0, end: $input.val().length })
.press('backspace')
.change();

assert.strictEqual(colorBox.option('value'), '');
assert.strictEqual(colorBox._colorView._currentColor.toHex(), '#000000', 'palette is reset');
assert.strictEqual(colorBox._colorView.option('value'), editAlphaChannel ? 'rgba(0, 0, 0, 1)' : null, 'palette value is reset');
});
});
});

QUnit.module('valueChanged handler should receive correct event', {
Expand Down
Loading