From e7844958fab463d7fb6947c68d59a5cf8c9d6a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Mon, 2 Dec 2024 17:49:24 +0100 Subject: [PATCH] Simplify logic and enable option to show modal at start --- panel/layout/modal.py | 11 +++-------- panel/models/modal.ts | 2 ++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/panel/layout/modal.py b/panel/layout/modal.py index 5a067317dc..a9edf9ff36 100644 --- a/panel/layout/modal.py +++ b/panel/layout/modal.py @@ -44,19 +44,14 @@ def _get_model( return super()._get_model(doc, root, parent, comm) def show(self): - self._send_event(ModalDialogEvent, open=True) + self.open = True def hide(self): - self._send_event(ModalDialogEvent, open=False) + self.open = False def toggle(self): - self._send_event(ModalDialogEvent, open=not self.open) + self.open = not self.open @param.depends("open", watch=True) def _open(self): self._send_event(ModalDialogEvent, open=self.open) - - def _process_param_change(self, msg): - msg = super()._process_param_change(msg) - msg.pop("open", None) - return msg diff --git a/panel/models/modal.ts b/panel/models/modal.ts index 05c8a7a7eb..735603cbd0 100644 --- a/panel/models/modal.ts +++ b/panel/models/modal.ts @@ -124,6 +124,8 @@ export class ModalView extends BkColumnView { this.model.open = false dialog.style.display = "none" }) + + if (this.model.open) { this.modal.show() } } update_close_button(): void {