Skip to content
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

[BUG] wrong sorting of registered pages by ordering #2564

Closed
gothicVI opened this issue Jun 14, 2023 · 0 comments · Fixed by #2565
Closed

[BUG] wrong sorting of registered pages by ordering #2564

gothicVI opened this issue Jun 14, 2023 · 0 comments · Fixed by #2565

Comments

@gothicVI
Copy link
Contributor

gothicVI commented Jun 14, 2023

Describe your context
Please provide us your environment, so we can easily reproduce the issue.

dash                              2.10.2
dash-ag-grid                      2.1.0
dash-bootstrap-components         1.4.1
dash-core-components              2.0.0
dash-html-components              2.0.0
dash-table                        5.0.0

Describe the bug
Hi,

I have an app where I add pages via:

register_page(
    __name__,
    path='/xxx',
    order=n,
    name="yyy",
    title="zzz"
)

where everything works fine as long as I have only 10 pages, i.e., n = 0,...,9.

As soon as I add an eleventh page and n turns into a two digit number, the new pages is entered as the third one, i.e., the sorting becomes: 0, 1, 10, 2, ..., 9.
This can also be seen by printing the page_registry in the global layout where I generate the navigation bar.

The error is due to the string cast here: https://github.com/plotly/dash/blob/dev/dash/_pages.py#L361

A workaround is to replace the above line with

key=lambda i: (str(i.get("order", i["module"])).zfill(9), i["module"]),

which prepends the order integer return with zeros to ensure correct sorting.
It is a dirty workaround as it would brake again when we have more then 100000000 pages but who would do that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant