fix(showcase): tear down modal listeners

This commit is contained in:
Will Miao
2025-11-27 18:00:59 +08:00
parent ecb512995c
commit 0254c9d0e9
3 changed files with 135 additions and 14 deletions

View File

@@ -454,6 +454,8 @@ export async function showModelModal(model, modelType) {
</div>
`;
let showcaseCleanup;
const onCloseCallback = function() {
// Clean up all handlers when modal closes for LoRA
const modalElement = document.getElementById(modalId);
@@ -461,6 +463,10 @@ export async function showModelModal(model, modelType) {
modalElement.removeEventListener('click', modalElement._clickHandler);
delete modalElement._clickHandler;
}
if (showcaseCleanup) {
showcaseCleanup();
showcaseCleanup = null;
}
};
modalManager.showModal(modalId, content, null, onCloseCallback);
@@ -475,7 +481,7 @@ export async function showModelModal(model, modelType) {
currentVersionId: civitaiVersionId,
});
setupEditableFields(modelWithFullData.file_path, modelType);
setupShowcaseScroll(modalId);
showcaseCleanup = setupShowcaseScroll(modalId);
setupTabSwitching({
onTabChange: async (tab) => {
if (tab === 'versions') {