feat(context-menu): prevent duplicate NSFW selector initialization

Add initialization tracking to prevent multiple event listener attachments
in context menu components. Use dataset.initialized flag to ensure NSFW
selector events are only set up once per component instance.

In ModelContextMenuMixin, replace DOM elements and reattach event listeners
to avoid duplicates when components are reinitialized. This fixes issues
where multiple click handlers could be attached to the same elements.
This commit is contained in:
Will Miao
2025-10-17 10:52:02 +08:00
parent 61101a7ad0
commit 0ecbdf6f39
5 changed files with 35 additions and 15 deletions

View File

@@ -11,9 +11,10 @@ export class CheckpointContextMenu extends BaseContextMenu {
this.modelType = 'checkpoint';
this.resetAndReload = resetAndReload;
// Initialize NSFW Level Selector events
if (this.nsfwSelector) {
// Initialize NSFW Level Selector events only if not already initialized
if (this.nsfwSelector && !this.nsfwSelector.dataset.initialized) {
this.initNSFWSelector();
this.nsfwSelector.dataset.initialized = 'true';
}
}