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

Prevent tabulator from overlapping when max_height is set #7403

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
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).not_to_have_css('max-height', '200px')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like an odd test, why would I have max-height set to 200px in the first place? Seems like it should check that max-height is unset instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay updated--seems counterintuitive to use to_have_css to check for null, but I guess that's the only way!

assert table.bounding_box()['height'] >= 200


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