Update the popover management to work with origin rerenders, and rerendering the popovers directly.

This commit is contained in:
Oliver-Akins 2025-03-15 18:35:24 -06:00
parent 69bf712eca
commit 96e4d09e7b
4 changed files with 93 additions and 29 deletions

View file

@ -31,6 +31,13 @@ export function GenericAppMixin(HandlebarsApp) {
};
// #endregion
// #region Instance Data
/** @type {Map<string, PopoverEventManager>} */
_popoverManagers = new Map();
/** @type {Map<number, string>} */
_hookIDs = new Map();
// #endregion
// #region Lifecycle
/**
* @override
@ -45,6 +52,13 @@ export function GenericAppMixin(HandlebarsApp) {
};
};
async _onRender() {
await super._onRender();
for (const manager of this._popoverManagers.values()) {
manager.render();
};
};
async _preparePartContext(partId, ctx, opts) {
ctx = await super._preparePartContext(partId, ctx, opts);
delete ctx.document;
@ -60,6 +74,22 @@ export function GenericAppMixin(HandlebarsApp) {
return ctx;
};
_tearDown(options) {
// Clear all popovers associated with the app
for (const manager of this._popoverManagers.values()) {
manager.destroy();
};
this._popoverManagers.clear();
// Remove any hooks added for this app
for (const [id, hook] of this._hookIDs.entries()) {
Hooks.off(hook, id);
};
this._hookIDs.clear();
super._tearDown(options);
};
// #endregion
// #region Actions