Skip to content

Commit

Permalink
Prevent tabulator from overlapping when max_height is set (#7403)
Browse files Browse the repository at this point in the history
* limit tabulator height with max height

* use maxHeight config

* reverse logic
  • Loading branch information
ahuang11 authored Oct 15, 2024
1 parent 3febd33 commit ced01e4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions panel/models/tabulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,9 @@ export class DataTabulatorView extends HTMLBoxView {
},
rowFormatter: (row: any) => this._render_row(row, false),
}
if (this.model.max_height != null) {
configuration.maxHeight = this.model.max_height
}
if (this.model.pagination === "remote") {
configuration.ajaxURL = "http://panel.pyviz.org"
configuration.sortMode = "remote"
Expand Down
26 changes: 26 additions & 0 deletions panel/tests/ui/widgets/test_tabulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,32 @@ def test_tabulator_patch_no_height_resize(page):
wait_until(lambda: page.locator('.pnx-tabulator').evaluate(at_bottom_script), page)


def test_tabulator_max_height_set(page):
df = pd.DataFrame({'col': np.random.random(100)})
widget = Tabulator(df, max_height=200)

serve_component(page, widget)

table = page.locator('.pnx-tabulator')
expect(table).to_have_css('max-height', '200px')
assert table.bounding_box()['height'] <= 200


def test_tabulator_max_height_unset(page):
"""
If max_height is not set, Tabulator should not set it to null;
else there's some recursion issues in the console and lag
"""
df = pd.DataFrame({'col': np.random.random(100)})
widget = Tabulator(df)

serve_component(page, widget)

table = page.locator('.pnx-tabulator')
expect(table).to_have_css('max-height', 'none')
assert table.bounding_box()['height'] >= 200


@pytest.mark.parametrize(
'pagination', ('local', 'remote', None)
)
Expand Down

0 comments on commit ced01e4

Please # to comment.