Skip to content

Commit

Permalink
stop collecting zombie HTMLDialogElements
Browse files Browse the repository at this point in the history
fix #16900
  • Loading branch information
schlawg authored Feb 13, 2025
1 parent b1f660c commit 20d3562
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ui/analyse/src/study/chapterNewForm.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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<ChapterTab>(
'analyse.study.form.tab',
Expand Down Expand Up @@ -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', [
Expand Down

0 comments on commit 20d3562

Please sign in to comment.