1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Handling onBlur event to detect iframe click

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-03-17 12:18:16 +03:00
parent 1aff341f0e
commit 51c5ecab2d

View File

@ -82,6 +82,7 @@ export class Menu extends React.Component<MenuProps, State> {
window.addEventListener("click", this.onClickOutside, true); window.addEventListener("click", this.onClickOutside, true);
window.addEventListener("scroll", this.onScrollOutside, true); window.addEventListener("scroll", this.onScrollOutside, true);
window.addEventListener("contextmenu", this.onContextMenu, true); window.addEventListener("contextmenu", this.onContextMenu, true);
window.addEventListener("blur", this.onBlur, true);
} }
componentWillUnmount() { componentWillUnmount() {
@ -232,6 +233,12 @@ export class Menu extends React.Component<MenuProps, State> {
} }
} }
onBlur() {
if (document.activeElement?.tagName == "IFRAME") {
this.close();
}
}
protected bindRef(elem: HTMLUListElement) { protected bindRef(elem: HTMLUListElement) {
this.elem = elem; this.elem = elem;
} }