diff --git a/panel/tests/widgets/test_tables.py b/panel/tests/widgets/test_tables.py index 26ca7dbf29..a3d904d64f 100644 --- a/panel/tests/widgets/test_tables.py +++ b/panel/tests/widgets/test_tables.py @@ -2284,3 +2284,15 @@ def test_bokeh_formatter_column_with_no_textalign_but_text_align_set(document, c model = table.get_root(document, comm) assert model.configuration['columns'][1]['hozAlign'] == 'center' + + +def test_selection_cleared_remote_pagination_new_values(document, comm): + df = pd.DataFrame(range(200)) + table = Tabulator(df, page_size=50, pagination="remote", selectable="checkbox") + table.selection = [1, 2, 3] + + table.value = df + assert table.selection == [1, 2, 3] + + table.value = df.copy() + assert table.selection == [] diff --git a/panel/widgets/tables.py b/panel/widgets/tables.py index c71ddae130..c1899ccb02 100644 --- a/panel/widgets/tables.py +++ b/panel/widgets/tables.py @@ -1191,6 +1191,7 @@ def __init__(self, value=None, **params): super().__init__(value=value, **params) self._configuration = configuration self.param.watch(self._update_children, self._content_params) + self.param.watch(self._clear_selection_remote_pagination, 'value') if click_handler: self.on_click(click_handler) if edit_handler: @@ -1596,6 +1597,10 @@ def _update_max_page(self): for ref, (model, _) in self._models.items(): self._apply_update([], {'max_page': max_page}, model, ref) + def _clear_selection_remote_pagination(self, event): + if event.new is not event.old and self.pagination == 'remote': + self.selection = [] + def _update_selected(self, *events: param.parameterized.Event, indices=None): kwargs = {} if self.pagination == 'remote' and self.value is not None: