Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Tabulator redraw is called after full render #7305

Merged
merged 5 commits into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions panel/models/tabulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ export class DataTabulatorView extends HTMLBoxView {
_lastHorizontalScrollbarLeftPosition: number = 0
_applied_styles: boolean = false
_building: boolean = false
_redrawing: boolean = false
_debounced_redraw: any = null
_restore_scroll: boolean | "horizontal" | "vertical" = false
_updating_scroll: boolean = false
Expand Down Expand Up @@ -491,9 +492,10 @@ export class DataTabulatorView extends HTMLBoxView {
}

redraw(columns: boolean = true, rows: boolean = true): void {
if (this._building || this.tabulator != null) {
if (this._building || this.tabulator == null || this._redrawing) {
return
}
this._redrawing = true
if (columns && (this.tabulator.columnManager.element != null)) {
this.tabulator.columnManager.redraw(true)
}
Expand All @@ -502,20 +504,22 @@ export class DataTabulatorView extends HTMLBoxView {
this.renderChildren()
this.setStyles()
}
this._redrawing = false
this._restore_scroll = true
}

override after_layout(): void {
super.after_layout()
if (this.tabulator != null && this._initializing) {
const finished = this.root.has_finished()
if (this.tabulator != null && this._initializing && !this._building && finished) {
this._initializing = false
this.redraw()
}
this._initializing = false
}

override after_resize(): void {
super.after_resize()
if (!this._is_scrolling) {
if (!this._is_scrolling && !this._redrawing) {
this._debounced_redraw()
}
}
Expand Down Expand Up @@ -643,7 +647,6 @@ export class DataTabulatorView extends HTMLBoxView {
}

tableBuilt(): void {
this._building = false
this.setSelection()
this.renderChildren()
this.setStyles()
Expand Down Expand Up @@ -690,6 +693,20 @@ export class DataTabulatorView extends HTMLBoxView {
this.setMaxPage()
this.tabulator.setPage(this.model.page)
}
this._building = false
if (this._initializing && this.root.has_finished()) {
this._initializing = false
this.redraw()
} else if (!this.root.has_finished()) {
const finalize = () => {
if (this.root.has_finished()) {
this._initializing = false
} else {
setTimeout(finalize, 10)
}
}
setTimeout(finalize, 10)
}
}

requestPage(page: number, sorters: any[]): Promise<void> {
Expand Down
Loading