Fix nested popups being shown if parent is hidden

This commit is contained in:
toasted-nutbread 2019-09-11 21:32:27 -04:00
parent ec816e6767
commit bab6a13bfb

View File

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