Skip to content

Commit

Permalink
revert excess part of the previous solution
Browse files Browse the repository at this point in the history
  • Loading branch information
ksercs committed Dec 23, 2024
1 parent 26c6260 commit 5e0c998
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,19 +309,6 @@ const DropDownList = DropDownEditor.inherit({
return selectedItem;
},

_shouldResetInputText(): boolean {
if (!this._isEditable()) {
return false;
}

const isTextEqualToInitialText = this._isTextEqualToInitial();
const isValueEqualToInitial = this._isValueEqualToInitial();

const shouldResetInputText: boolean = !isTextEqualToInitialText && isValueEqualToInitial;

return shouldResetInputText;
},

_resetInputText(): void {
this._renderInputValue({ renderOnly: true });
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,6 @@ const TextEditorBase = Editor.inherit({

this._renderValue();
this._renderLabel();

const { text } = this.option();

this._initialText = text;
},

_render() {
Expand Down Expand Up @@ -285,7 +281,6 @@ const TextEditorBase = Editor.inherit({
this._$beforeButtonsContainer = null;
this._$afterButtonsContainer = null;
this._$textEditorContainer = null;
this._initialText = null;
this.callBase();
},

Expand Down Expand Up @@ -921,33 +916,19 @@ const TextEditorBase = Editor.inherit({
},

_resetInputText(): void {
this._options.silent('text', this._initialText);
this._options.silent('text', this._initialValue);
this._renderValue();
},

_isTextEqualToInitial(): boolean {
const { text } = this.option();
const initialText = this._initialText;

return text === initialText;
},

_isValueEqualToInitial(): boolean {
const { value } = this.option();
const initialValue = this._initialValue;

return value === initialValue;
},

_shouldResetInputText(): boolean {
const shouldResetInputText = this._isValueEqualToInitial();

return shouldResetInputText;
},

_resetToInitialValue() {
const shouldResetInputText = this._shouldResetInputText();

const shouldResetInputText = this._isValueEqualToInitial();
if (shouldResetInputText) {
this._resetInputText();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,6 @@ QUnit.module('reset method', moduleConfig, () => {
const byKeyHandler = sinon.spy(key => key);
const items = ['initial'];
const additionalText = 'NEW';
let expectedByKeyCallCount = 1;

const dataSource = new DataSource({
store: new CustomStore({
Expand All @@ -1592,11 +1591,10 @@ QUnit.module('reset method', moduleConfig, () => {
const keyboard = keyboardMock($input);

const assertState = (expectedText, messageComment) => {
expectedByKeyCallCount += expectedText !== items[0];
assert.strictEqual($input.val(), expectedText, `input text is "${expectedText}" ${messageComment}`);
assert.strictEqual(instance.option('text'), expectedText, `text option is "${expectedText}" ${messageComment}`);
assert.strictEqual(instance.option('value'), items[0], `value option is "${items[0]}" ${messageComment}`);
assert.strictEqual(byKeyHandler.callCount, expectedByKeyCallCount, 'no additional byKey for initial item is presented');
assert.strictEqual(byKeyHandler.callCount, 1, 'no additional byKey for initial item is presented');
};

assertState(items[0], 'initially');
Expand Down

0 comments on commit 5e0c998

Please sign in to comment.