diff --git a/packages/devextreme/js/ui/number_box/number_box.mask.js b/packages/devextreme/js/ui/number_box/number_box.mask.js index ae910d15a5a6..ef5675f11973 100644 --- a/packages/devextreme/js/ui/number_box/number_box.mask.js +++ b/packages/devextreme/js/ui/number_box/number_box.mask.js @@ -404,13 +404,20 @@ const NumberBoxMask = NumberBoxBase.inherit({ }, _tryParse: function(text, selection, char) { + const isTextSelected = selection.start !== selection.end; + const isWholeTextSelected = isTextSelected && selection.start === 0 && selection.end === text.length; + const decimalSeparator = number.getDecimalSeparator(); + + if(isWholeTextSelected && char === decimalSeparator) { + return 0; + } + const editedText = this._replaceSelectedText(text, selection, char); const format = this._getFormatPattern(); - const isTextSelected = selection.start !== selection.end; + let parsedValue = this._getParsedValue(editedText, format); const maxPrecision = !format.parser && this._getPrecisionLimits(editedText).max; const isValueChanged = parsedValue !== this._parsedValue; - const decimalSeparator = number.getDecimalSeparator(); const isDecimalPointRestricted = char === decimalSeparator && maxPrecision === 0; const isUselessCharRestricted = !isTextSelected && !isValueChanged && char !== MINUS && !this._isValueIncomplete(editedText) && this._isStub(char); diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/numberBoxParts/mask.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/numberBoxParts/mask.tests.js index a987777a1b2b..8a72f8d80c14 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/numberBoxParts/mask.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/numberBoxParts/mask.tests.js @@ -665,6 +665,19 @@ QUnit.module('format: fixed point format', moduleConfig, () => { assert.strictEqual(this.instance.option('text'), '4.65'); }); + + QUnit.test('pressing "." should clear selected text if it contains a decimal separator (T1199553)', function(assert) { + this.instance.option({ + format: '0#.00', + value: 123.45 + }); + + this.keyboard + .caret({ start: 0, end: 6 }) + .type('.'); + + assert.strictEqual(this.input.val(), '0.00', 'mask value is cleared'); + }); }); QUnit.module('format: minimum and maximum', moduleConfig, () => {