From 2109334cee3b6c3fcb89a2491178c4c00fcbc6e0 Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Fri, 10 Jul 2020 12:40:25 +1000 Subject: [PATCH] Autocomplete: Fix closing slash inserter with ESC Ensure that the slash inserter closes when the user presses ESC by properly resetting both `autocompleter` and `AutocompleterUI` (added in 3156d0b) from component state. Also prevent the block editor from going into Select mode by stopping event propagation when the Autocomplete component handles a key press. --- packages/components/src/autocomplete/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/components/src/autocomplete/index.js b/packages/components/src/autocomplete/index.js index 3c66e5f4d21cf..38a5a0d58fd6b 100644 --- a/packages/components/src/autocomplete/index.js +++ b/packages/components/src/autocomplete/index.js @@ -409,7 +409,7 @@ export class Autocomplete extends Component { break; case ESCAPE: - this.setState( { autocompleter: null } ); + this.setState( { autocompleter: null, AutocompleterUI: null } ); break; case ENTER: @@ -428,6 +428,7 @@ export class Autocomplete extends Component { // Any handled keycode should prevent original behavior. This relies on // the early return in the default case. event.preventDefault(); + event.stopPropagation(); } componentDidUpdate( prevProps ) {