Skip to content

Commit

Permalink
Simplify logic and enable option to show modal at start
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Dec 2, 2024
1 parent 1bb3c55 commit e784495
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 3 additions & 8 deletions panel/layout/modal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions panel/models/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e784495

Please sign in to comment.