Skip to content

Commit

Permalink
Merge pull request #10873 from ckeditor/ck/10712-disable-replace-when…
Browse files Browse the repository at this point in the history
…-find-input-is-dirty

Fix (find-and-replace): Replace functionality no longer replaces text when 'Replace with...' input is focused and user hits `enter` key but search criteria changed. Closes #10712.
  • Loading branch information
niegowski committed Nov 23, 2021
2 parents e283548 + cdcb4bc commit 4bc9646
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ export default class FindAndReplaceFormView extends View {
this._findButtonView.fire( 'execute' );
}
stopPropagationAndPreventDefault( event );
} else if ( target === this._replaceInputView.fieldView.element ) {
} else if ( target === this._replaceInputView.fieldView.element && !this.isDirty ) {
this._replaceButtonView.fire( 'execute' );
stopPropagationAndPreventDefault( event );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,20 @@ describe( 'FindAndReplaceFormView', () => {
sinon.assert.notCalled( spy );
} );

it( 'skips command execution on "enter" when search phrase input is dirty', () => {
const keyEvtData = {
keyCode: keyCodes.enter,
target: view._replaceInputView.fieldView.element
};

const spy = sinon.spy( view._replaceButtonView, 'fire' );

view.isDirty = true;
view._keystrokes.press( keyEvtData );

sinon.assert.notCalled( spy );
} );

it( 'ignores "shift+enter" when pressed somewhere else', () => {
const keyEvtData = {
keyCode: keyCodes.enter,
Expand Down

0 comments on commit 4bc9646

Please sign in to comment.