Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#10712 Skip executing replace command when search input is dirty #10873

Merged
merged 1 commit into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
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