Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ann-marie-ward committed Jun 2, 2021
1 parent 596ad6d commit d662213
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/dash-table/derived/paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
38 changes: 38 additions & 0 deletions tests/selenium/test_pagination.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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() == []

0 comments on commit d662213

Please sign in to comment.