Skip to content
New issue

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

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

Already on GitHub? # 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 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
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 @@ -1086,7 +1086,7 @@

cell = page.locator('text="target"').first
# Scroll to the right
cell.scroll_into_view_if_needed()

Check failure on line 1089 in panel/tests/ui/widgets/test_tabulator.py

View workflow job for this annotation

GitHub Actions / ui:test-ui:macos-latest

test_tabulator_patch_no_horizontal_rescroll playwright._impl._errors.Error: Locator.scroll_into_view_if_needed: Element is not attached to the DOM Call log: attempting scroll into view action - waiting for element to be stable
page.wait_for_timeout(200)
bb = page.locator('text="tomodify"').bounding_box()
# Patch a cell in the latest column
Expand Down Expand Up @@ -1159,6 +1159,32 @@
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
Loading