Skip to content

Commit b3134ce

Browse files
r-farkhutdinovRuslan Farkhutdinov
andauthored
ColorBox: fix invalid value setting error (T1274477) (DevExpress#29023)
Co-authored-by: Ruslan Farkhutdinov <[email protected]>
1 parent 6a61097 commit b3134ce

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

packages/devextreme/js/__internal/ui/color_box/m_color_box.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,7 @@ const ColorBox = (DropDownEditor as any).inherit({
320320
},
321321

322322
_optionChanged(args) {
323-
const { value } = args;
324-
const { name } = args;
323+
const { name, value } = args;
325324

326325
switch (name) {
327326
case 'value':

packages/devextreme/js/__internal/ui/color_box/m_color_view.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ const ColorView = (Editor as any).inherit({
884884
}
885885

886886
this._updateByDrag = false;
887-
this.callBase(args);
887+
this.callBase({ ...args, value: this.option('value') });
888888
break;
889889
case 'matchValue':
890890
this._setBaseColor(value);

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,21 @@ QUnit.module('Color Box', {
500500
assert.equal(colorBox.option('value'), 'rgba(100, 0, 0, 1)');
501501
});
502502

503+
QUnit.test('In "instantly" mode value should not throw an error when invalid value is set (T1274981)', function(assert) {
504+
try {
505+
const colorBox = showColorBox.call(this, {
506+
applyValueMode: 'instantly',
507+
}).dxColorBox('instance');
508+
509+
colorBox.option('value', 'invalid');
510+
assert.strictEqual(colorBox.option('value'), '#000000');
511+
512+
assert.ok(true, 'no errors');
513+
} catch(e) {
514+
assert.ok(false, `The '${e.message}' is raised`);
515+
}
516+
});
517+
503518

504519
QUnit.test('Option changes', function(assert) {
505520
const colorBox = showColorBox.call(this).dxColorBox('instance');

0 commit comments

Comments
 (0)