diff --git a/panel/models/tabulator.ts b/panel/models/tabulator.ts index c6221c8309..3cc745b2a3 100644 --- a/panel/models/tabulator.ts +++ b/panel/models/tabulator.ts @@ -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" diff --git a/panel/tests/ui/widgets/test_tabulator.py b/panel/tests/ui/widgets/test_tabulator.py index 959e9a9d24..8663a597f2 100644 --- a/panel/tests/ui/widgets/test_tabulator.py +++ b/panel/tests/ui/widgets/test_tabulator.py @@ -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) )