From 5fc69728e8476e7bf4f1801f34913192f815e277 Mon Sep 17 00:00:00 2001 From: Ann Marie Ward Date: Tue, 1 Jun 2021 11:21:42 -0700 Subject: [PATCH 1/6] issue #834 fix when pagination doesn't work when more than one table is on the page --- src/dash-table/components/Table/Table.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dash-table/components/Table/Table.less b/src/dash-table/components/Table/Table.less index 471e4f8ac..4118a020a 100644 --- a/src/dash-table/components/Table/Table.less +++ b/src/dash-table/components/Table/Table.less @@ -143,7 +143,7 @@ .dash-table-container { .previous-next-container { - float: right; + text-align: right; padding: 5px 0px; .page-number { From 596ad6dde5e9fe320f0549a1b220b95a13e3fc38 Mon Sep 17 00:00:00 2001 From: Ann Marie Ward Date: Tue, 1 Jun 2021 11:41:35 -0700 Subject: [PATCH 2/6] issue #834 CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdb870513..bdde08012 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Fixed +- [#907](https://github.com/plotly/dash-table/pull/907) Fix a bug where pagination did not work or was not visible. [#834](https://github.com/plotly/dash-table/issues/834) + + + ### Added - [#545](https://github.com/plotly/dash-table/issues/545) - Case insensitive filtering From d66221328e4e8f1b6e770dcb877d2387b0687b48 Mon Sep 17 00:00:00 2001 From: Ann Marie Ward Date: Wed, 2 Jun 2021 11:08:20 -0700 Subject: [PATCH 3/6] issue #892 and #698 --- CHANGELOG.md | 5 ++-- src/dash-table/derived/paginator.ts | 5 ++++ tests/selenium/test_pagination.py | 38 +++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdde08012..628299e9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Fixed -- [#907](https://github.com/plotly/dash-table/pull/907) Fix a bug where pagination did not work or was not visible. [#834](https://github.com/plotly/dash-table/issues/834) - +- [#907](https://github.com/plotly/dash-table/pull/907) + - Fix a bug where pagination did not work or was not visible. [#834](https://github.com/plotly/dash-table/issues/834) + - Fix a bug where if you are on a page that no longer exists after the data is updated, no data is displayed. [#892](https://github.com/plotly/dash-table/issues/892) ### Added diff --git a/src/dash-table/derived/paginator.ts b/src/dash-table/derived/paginator.ts index 98b134bc4..84ca9b556 100644 --- a/src/dash-table/derived/paginator.ts +++ b/src/dash-table/derived/paginator.ts @@ -50,6 +50,11 @@ function makePaginator(params: IPaginatorParams | null): IPaginator { const {setProps, page_count} = params; let {page_current} = params; + if (page_count && page_count - 1 < page_current) { + page_current = 0; + updatePage(); + } + function updatePage() { setProps({ page_current, diff --git a/tests/selenium/test_pagination.py b/tests/selenium/test_pagination.py index 9c45c217a..bbf1620a5 100644 --- a/tests/selenium/test_pagination.py +++ b/tests/selenium/test_pagination.py @@ -1,6 +1,7 @@ import dash from dash.dependencies import Input, Output from dash.exceptions import PreventUpdate +import dash_html_components as html from dash_table import DataTable @@ -205,3 +206,40 @@ def test_tpag010_limits_page(test): assert target.paging.current.get_value() == "10" assert test.get_log_errors() == [] + + +def get_app2(): + app = dash.Dash(__name__) + + app.layout = html.Div( + [ + html.Button("i=20", id="button", n_clicks=0), + DataTable( + id="table", + page_size=5, + columns=[{"name": "i", "id": "i"}, {"name": "square", "id": "square"}], + data=[{"i": i, "square": i ** 2} for i in range(50 + 1)], + page_current=5, + ), + ] + ) + + @app.callback(Output("table", "data"), Input("button", "n_clicks")) + def update_table_data(n): + return ( + [{"i": i, "square": i ** 2} for i in range(20 + 1)] + if n > 0 + else dash.no_update + ) + + return app + + +def test_tpag011_valid_page(test): + test.start_server(get_app2()) + + target = test.table("table") + test.find_element("#button").click() + + assert target.paging.current.get_value() == "1" + assert test.get_log_errors() == [] From 296b76743aa92354eda136704c9b32fad047aebf Mon Sep 17 00:00:00 2001 From: Ann Marie Ward Date: Thu, 3 Jun 2021 09:43:43 -0700 Subject: [PATCH 4/6] added test --- tests/selenium/test_pagination.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/selenium/test_pagination.py b/tests/selenium/test_pagination.py index bbf1620a5..209335039 100644 --- a/tests/selenium/test_pagination.py +++ b/tests/selenium/test_pagination.py @@ -2,6 +2,7 @@ from dash.dependencies import Input, Output from dash.exceptions import PreventUpdate import dash_html_components as html +import dash_core_components as dcc from dash_table import DataTable @@ -221,6 +222,7 @@ def get_app2(): data=[{"i": i, "square": i ** 2} for i in range(50 + 1)], page_current=5, ), + dcc.Graph(), ] ) @@ -243,3 +245,11 @@ def test_tpag011_valid_page(test): assert target.paging.current.get_value() == "1" assert test.get_log_errors() == [] + + +def test_tpage012_pagination_row_visible(test): + test.start_server((get_app2())) + + test.table("table").is_ready() + + test.percy_snapshot("test_tpage012 Pagination row visible") From 41b7568bbd626edbcc06893f3b05ede8b5f9f871 Mon Sep 17 00:00:00 2001 From: Ann Marie Ward Date: Thu, 3 Jun 2021 11:42:37 -0700 Subject: [PATCH 5/6] updated test --- tests/selenium/test_pagination.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tests/selenium/test_pagination.py b/tests/selenium/test_pagination.py index 209335039..4a90feb96 100644 --- a/tests/selenium/test_pagination.py +++ b/tests/selenium/test_pagination.py @@ -246,10 +246,5 @@ def test_tpag011_valid_page(test): assert target.paging.current.get_value() == "1" assert test.get_log_errors() == [] - -def test_tpage012_pagination_row_visible(test): - test.start_server((get_app2())) - test.table("table").is_ready() - - test.percy_snapshot("test_tpage012 Pagination row visible") + test.percy_snapshot("test_tpage011 Pagination row visible") From f11dbd5c4b37dd8a0ecb81cb9b1049d0ce4dc97b Mon Sep 17 00:00:00 2001 From: AnnMarieW <72614349+AnnMarieW@users.noreply.github.com> Date: Fri, 4 Jun 2021 07:03:54 -0700 Subject: [PATCH 6/6] Update tests/selenium/test_pagination.py Co-authored-by: Alex Johnson --- tests/selenium/test_pagination.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/selenium/test_pagination.py b/tests/selenium/test_pagination.py index 4a90feb96..dee2bf1b5 100644 --- a/tests/selenium/test_pagination.py +++ b/tests/selenium/test_pagination.py @@ -247,4 +247,4 @@ def test_tpag011_valid_page(test): assert test.get_log_errors() == [] test.table("table").is_ready() - test.percy_snapshot("test_tpage011 Pagination row visible") + test.percy_snapshot("test_tpag011 Pagination row visible")