Fix bug in which Console was attempting to detach the suggestions completer even when it wasn't rendered. (#138030) (#138155)

(cherry picked from commit dc20c94094)

Co-authored-by: CJ Cenizal <cj.cenizal@elastic.co>
This commit is contained in:
Kibana Machine 2022-08-04 14:42:04 -04:00 committed by GitHub
parent 200a1b7ad0
commit f05707ef90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -229,7 +229,10 @@ export class LegacyCoreEditor implements CoreEditor {
}
detachCompleter() {
return (this.editor as unknown as { completer: { detach(): void } }).completer.detach();
// In some situations we need to detach the autocomplete suggestions element manually,
// such as when navigating away from Console when the suggestions list is open.
const completer = (this.editor as unknown as { completer: { detach(): void } }).completer;
return completer?.detach();
}
private forceRetokenize() {