Skip to content

Tabulator: fix index out of bound error when updating table value with selected row and add_filter #7822

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
31 changes: 31 additions & 0 deletions panel/tests/ui/widgets/test_tabulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,37 @@
assert widget.selected_dataframe.equals(expected_selected)


def test_tabulator_selection_add_filter_edit_value(page, exception_handler_accumulator):
# https://github.com/holoviz/panel/issues/7525
df = pd.DataFrame(
{"col": ["a", "a", "b", "b", "b"]},
index=["idx0", "idx1", "idx2", "idx3", "idx4"],
)
w_col = Select(value="b", options=["a", "b"])
widget = Tabulator(df, selectable=1)

def f(df, pattern):
return df[df['col'].str.contains(pattern)]

widget.add_filter(bind(f, pattern=w_col))

serve_component(page, widget)

# Click on the first row of the index column to select the row
c0 = page.locator('text="idx4"')
c0.wait_for()
c0.click()

b3 = page.locator('text="b"').nth(2)
b3.click()
editable_cell = page.locator('input[type="text"]')
editable_cell.fill("bcd")
editable_cell.press('Enter')
widget.param.trigger('value')
wait_until(lambda: widget.selection == [4], page)
assert not exception_handler_accumulator

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

View workflow job for this annotation

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

test_tabulator_selection_add_filter_edit_value AssertionError: assert not [IndexError('index 4 is out of bounds for axis 0 with size 3')]

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

View workflow job for this annotation

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

test_tabulator_selection_add_filter_edit_value AssertionError: assert not [IndexError('index 4 is out of bounds for axis 0 with size 3')]


@pytest.mark.parametrize('embed_content', [False, True])
def test_tabulator_row_content(page, df_mixed, embed_content):
widget = Tabulator(
Expand Down
Loading