From 20d3562aa10ac81abe1414f5f798389ccf7bed28 Mon Sep 17 00:00:00 2001 From: Jonathan Gamble <101470903+schlawg@users.noreply.github.com> Date: Wed, 12 Feb 2025 20:49:51 -0600 Subject: [PATCH] stop collecting zombie HTMLDialogElements fix #16900 --- ui/analyse/src/study/chapterNewForm.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/analyse/src/study/chapterNewForm.ts b/ui/analyse/src/study/chapterNewForm.ts index 39cc95c11ac0..f47a7da9fde8 100644 --- a/ui/analyse/src/study/chapterNewForm.ts +++ b/ui/analyse/src/study/chapterNewForm.ts @@ -1,6 +1,6 @@ import { parseFen } from 'chessops/fen'; import { defined, prop, type Prop, toggle } from 'common'; -import { snabDialog, alert } from 'common/dialog'; +import { type Dialog, snabDialog, alert } from 'common/dialog'; import * as licon from 'common/licon'; import { bind, bindSubmit, onInsert, looseH as h, dataIcon, type VNode } from 'common/snabbdom'; import { storedProp } from 'common/storage'; @@ -29,7 +29,10 @@ export const fieldValue = (e: Event, id: string) => export class StudyChapterNewForm { readonly multiPgnMax = 64; variants: Variant[] = []; - isOpen = toggle(false); + dialog: Dialog | undefined; + isOpen = toggle(false, val => { + if (!val) this.dialog?.close(); + }); initial = toggle(false); tab = storedProp( 'analyse.study.form.tab', @@ -142,11 +145,16 @@ export function view(ctrl: StudyChapterNewForm): VNode { return snabDialog({ class: 'chapter-new', onClose() { + ctrl.dialog = undefined; ctrl.isOpen(false); ctrl.redraw(); }, modal: true, noClickAway: true, + onInsert: dlg => { + ctrl.dialog = dlg; + dlg.show(); + }, vnodes: [ activeTab !== 'edit' && h('h2', [