Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Page selection disappears when number of pages decreases to one #892

Description

@mhnrchs

dash-table version: 4.11.3
Browsers tested: Chromium 78.0.3904.70, Edge 83.0.478.58

On tables where the number of entries (and in consqeuence the number of pages) may change dynamically, dash-table will remain on the currently selected page. If I am on page 4/8 and the number of pages reduces to 2, I will then be on page 4/2.

When this happens, I can use the page selectors to navigate back to previous pages. However, when the number of pages decreases to 1, I am stuck on another page without any apparent way to navigate to the actual content.

Here is a simple example illustrating the issue:
pagechange

And here is the code used to produce the example above:

import dash
import dash_table
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

app = dash.Dash(__name__)

app.layout = html.Div([
    dcc.Input(
        id='input', type='number',
    ),
    dash_table.DataTable(
        id='table', page_size= 10,
        columns=[{'name':'i', 'id':'i'}, {'name':'square', 'id':'square'}],
    )
])

@app.callback(Output('table', 'data'),
                    Input('input', 'value'))
def update_table_data(val):
    if not val: val = 9
    return [{'i':i, 'square':i**2} for i in range(val+1)]

if __name__ == '__main__':
    app.run_server(debug=True)

This is especially bothersome if the number of table entries cannot be controlled by the user, because the user is then stuck on the non-existing page.

Possible solutions:

  • Automatically change pages when the currently selected page exceeds the new total number of pages: User is on page 4/8, number of pages reduces to 3 -> User is on page 3/3 or 1/3.
  • Do not hide the page selectors if the user is on another page than page 1, even when there is only 1 page in total. This would allow the user to navigate back to the content even in that case.

I am currently handling this by checking myself and updating page_current as needed, but a solution on the side of Dash would be preferred, as I don't think the current behaviour is intended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions