Merge pull request #208 from toasted-nutbread/fix-popup-orphans

Fix nested popups being shown if parent is hidden
This commit is contained in:
Alex Yatskov 2019-09-14 17:29:52 -07:00 committed by GitHub
commit ab2db771ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,12 +116,14 @@ class PopupProxyHost {
async termsShow(id, elementRect, writingMode, definitions, options, context) {
const popup = this.getPopup(id);
elementRect = this.jsonRectToDOMRect(popup, elementRect);
if (!PopupProxyHost.popupCanShow(popup)) { return false; }
return await popup.termsShow(elementRect, writingMode, definitions, options, context);
}
async kanjiShow(id, elementRect, writingMode, definitions, options, context) {
const popup = this.getPopup(id);
elementRect = this.jsonRectToDOMRect(popup, elementRect);
if (!PopupProxyHost.popupCanShow(popup)) { return false; }
return await popup.kanjiShow(elementRect, writingMode, definitions, options, context);
}
@ -129,6 +131,10 @@ class PopupProxyHost {
const popup = this.getPopup(id);
return popup.clearAutoPlayTimer();
}
static popupCanShow(popup) {
return popup.parent === null || popup.parent.isVisible();
}
}
PopupProxyHost.instance = PopupProxyHost.create();