Skip to content

Commit 80d1daa

Browse files
authored
Set Tabulator to render into explicit popup container (#7299)
1 parent 977e801 commit 80d1daa

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

panel/models/tabulator.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,7 @@ export class DataTabulatorView extends HTMLBoxView {
824824
paginationMode: this.model.pagination,
825825
paginationSize: this.model.page_size || 20,
826826
paginationInitialPage: 1,
827+
popupContainer: this.container,
827828
groupBy: this.groupBy,
828829
frozenRows: (row: any) => {
829830
return (this.model.frozen_rows.length > 0) ? this.model.frozen_rows.includes(row._row.data._index) : false
@@ -1152,6 +1153,9 @@ export class DataTabulatorView extends HTMLBoxView {
11521153
}
11531154
columns.push(button_column)
11541155
}
1156+
// We insert an empty last column to ensure select editor is rendered in correct position
1157+
// see: https://github.com/holoviz/panel/issues/7295
1158+
columns.push({width: 1, maxWidth: 1, minWidth: 1, resizable: false, cssClass: "empty", sorter: null})
11551159
return columns
11561160
}
11571161

panel/styles/models/tabulator.less

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,20 @@
44
.tabulator-row .row-content .bk-panel-models-markup-HTML {
55
white-space: normal;
66
}
7+
8+
.tabulator-cell.empty {
9+
width: 0px !important;
10+
padding: 0px !important
11+
}
12+
}
13+
14+
.tabulator-header {
15+
.tabulator-col.empty {
16+
min-width: 0px !important;
17+
width: 0px !important;
18+
border-right: unset !important;
19+
.tabulator-col-content {
20+
padding: 0px !important;
21+
}
22+
}
723
}

panel/tests/ui/io/test_convert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ def test_pyodide_test_convert_csv_app(http_serve, page, runtime, http_patch):
250250
expected_titles = ['index', 'date', 'Temperature', 'Humidity', 'Light', 'CO2', 'HumidityRatio', 'Occupancy']
251251

252252
titles = page.locator('.tabulator-col-title')
253-
expect(titles).to_have_count(1 + len(expected_titles), timeout=60 * 1000)
253+
expect(titles).to_have_count(2 + len(expected_titles), timeout=60 * 1000)
254254
titles = titles.all_text_contents()
255-
assert titles[1:] == expected_titles
255+
assert titles[1:-1] == expected_titles
256256

257257
assert [msg for msg in msgs if msg.type == 'error' and 'favicon' not in msg.location['url']] == []
258258

panel/tests/ui/widgets/test_tabulator.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def test_tabulator_default(page, df_mixed, df_mixed_as_string):
114114

115115
serve_component(page, widget)
116116

117-
expected_ncols = ncols + 2 # _index + index + data columns
117+
expected_ncols = ncols + 3 # _index + index + data columns + empty
118118

119119
# Check that the whole table content is on the page
120120
table = page.locator('.pnx-tabulator.tabulator')
@@ -234,13 +234,13 @@ def test_tabulator_buttons_display(page, df_mixed):
234234

235235
serve_component(page, widget)
236236

237-
expected_ncols = ncols + 3 # _index + index + data columns + button col
237+
expected_ncols = ncols + 4 # _index + index + data columns + button col + empty
238238

239239
# Check that an additional column has been added to the table
240240
# with no header title
241241
cols = page.locator(".tabulator-col")
242242
expect(cols).to_have_count(expected_ncols)
243-
button_col_idx = expected_ncols - 1
243+
button_col_idx = expected_ncols - 2
244244
assert not cols.nth(button_col_idx).get_attribute('tabulator-field')
245245
assert cols.nth(button_col_idx).inner_text() == '\xa0'
246246
assert cols.nth(button_col_idx).is_visible()
@@ -704,20 +704,20 @@ def test_tabulator_editors_tabulator_multiselect(page, exception_handler_accumul
704704
val = ['red', 'blue']
705705
for v in val:
706706
item = page.locator(f'.tabulator-edit-list-item:has-text("{v}")')
707-
item.click()
707+
item.evaluate("el => el.click()")
708708
# Validating the filters doesn't have a very nice behavior, you need to lose
709709
# focus on the multiselect by clicking somewhere else.
710710
# Delay required before clicking for the focus to be lost and the filters accounted for.
711711
page.wait_for_timeout(200)
712-
page.locator('text="foo1"').click()
712+
page.locator('text="foo1"').click(force=True)
713713

714714
cell.click()
715715
val = ['red', 'blue']
716716
for v in val:
717717
item = page.locator(f'.tabulator-edit-list-item:has-text("{v}")')
718-
item.click()
718+
item.evaluate("el => el.click()")
719719
page.wait_for_timeout(200)
720-
page.locator('text="foo1"').click()
720+
page.locator('text="foo1"').click(force=True)
721721

722722
assert not exception_handler_accumulator
723723

@@ -747,13 +747,13 @@ def test_tabulator_editors_nested(page, opt0, opt1):
747747
cells.nth(0).click()
748748
item = page.locator('.tabulator-edit-list-item', has_text=opt0)
749749
expect(item).to_have_count(1)
750-
item.click()
750+
item.click(force=True)
751751

752752
# Change the 1th column
753753
cells.nth(1).click()
754754
item = page.locator('.tabulator-edit-list-item', has_text=opt1)
755755
expect(item).to_have_count(1)
756-
item.click()
756+
item.click(force=True)
757757

758758
# Check the last column matches
759759
cells.nth(2).click()

0 commit comments

Comments
 (0)