mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
Fix bug where ESC was closing the Console autocompletion suggestions menu, but then also exiting edit mode. (#16500)
This commit is contained in:
parent
090866c514
commit
e5a10edb38
2 changed files with 73 additions and 53 deletions
|
@ -37,8 +37,8 @@ uiModules.get('kibana')
|
|||
<p class="kuiText kuiVerticalRhythmSmall">
|
||||
When you’re done, press Escape to stop editing.
|
||||
</p>
|
||||
</div>
|
||||
`);
|
||||
</div>`
|
||||
);
|
||||
|
||||
const uiAceTextbox = element.find('textarea');
|
||||
|
||||
|
@ -63,13 +63,33 @@ uiModules.get('kibana')
|
|||
enableOverlay();
|
||||
});
|
||||
|
||||
let isAutoCompleterOpen;
|
||||
|
||||
// We have to capture this event on the 'capture' phase, otherewise Ace will have already
|
||||
// dismissed the autocompleter when the user hits ESC.
|
||||
document.addEventListener('keydown', () => {
|
||||
const autoCompleter = document.querySelector('.ace_autocomplete');
|
||||
|
||||
if (!autoCompleter) {
|
||||
isAutoCompleterOpen = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// The autoComplete is just hidden when it's closed, not removed from the DOM.
|
||||
isAutoCompleterOpen = autoCompleter.style.display !== 'none';
|
||||
}, { capture: true });
|
||||
|
||||
uiAceTextbox.keydown((ev) => {
|
||||
if (ev.keyCode === keyCodes.ESCAPE) {
|
||||
// If the autocompletion context menu is open then we want to let ESC close it but
|
||||
// **not** exit out of editing mode.
|
||||
if (!isAutoCompleterOpen) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
enableOverlay();
|
||||
hint.focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
hint.click(startEditing);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue