Skip to content

Commit

Permalink
First show the content on modal on click
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Dec 2, 2024
1 parent c9ada92 commit 06aee3f
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions panel/models/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ export class ModalView extends BkColumnView {
UIElementView.prototype.render.call(this)
this.class_list.add(...this.css_classes())
this.create_modal()

for (const child_view of this.child_views) {
this.modal_children.append(child_view.el)
child_view.render()
child_view.after_render()
}
}

override async update_children(): Promise<void> {
Expand All @@ -72,6 +66,7 @@ export class ModalView extends BkColumnView {
id: "pnx_dialog",
class: "dialog-container bk-root",
"aria-hidden": "true",
style: {display: "none"},
} as any)

const dialog_overlay = div({class: "dialog-overlay"})
Expand All @@ -85,6 +80,11 @@ export class ModalView extends BkColumnView {
class: "dialog-content",
role: "document",
} as any)
for (const child_view of this.child_views) {
const target = child_view.rendering_target() ?? content
child_view.render_to(target)
}

this.close_button = button({
id: "pnx_dialog_close",
"data-a11y-dialog-hide": "",
Expand All @@ -100,11 +100,22 @@ export class ModalView extends BkColumnView {
content.append(this.close_button)
content.append(this.modal_children)
this.shadow_el.append(container)
let first_open = false

this.modal = new (window as any).A11yDialog(dialog)
this.update_close_button()
this.modal.on("show", () => { this.model.open = true })
this.modal.on("hide", () => { this.model.open = false })
this.modal.on("show", () => {
this.model.open = true
dialog.style.display = ""
if (!first_open) {
requestAnimationFrame(() => { this.invalidate_layout() })
first_open = true
}
})
this.modal.on("hide", () => {
this.model.open = false
dialog.style.display = "none"
})
}

update_close_button(): void {
Expand Down

0 comments on commit 06aee3f

Please sign in to comment.