plotly / plotly/dash

dcc.Location unable to handle path separator '/'

Open
#2,585 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
24.4k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
13

Description

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

  • replace the result of pip list | grep dash below
dash                      2.8.1
dash-ag-grid              2.0.0a1
dash-bootstrap-components 1.3.1
dash-core-components      2.0.0
dash-daq                  0.5.0
dash-html-components      2.0.0
dash-table                5.0.0
  • if frontend related, tell us your Browser, Version and OS

Bug exists in all browsers I have.

Describe the bug

I have the following code:

@callback(
        Output('url-output', 'pathname'), 
        [Input('tabs', 'active_tab'), Input('site-table', 'selectionChanged')],
        prevent_initial_call=True)
def url_manger(tab_id, site_selection):
    path = tab_id
    if site_selection:
        path += '/' + site_selection[0]['Site_id']
    return path

When site selection is activated, the new url is appended to the tab section of existing path: "site_tab/:site_id:" -> "site_tab/site_tab/:site_id:"; if tab is activated instead (site_selection = None), things work as expected.

If I change the delimiter from '/' slash to any other character, for example such as '_' lower dash, things work as expected; nothing gets appended to the path but the path is exactly the same as the return value.

Expected behavior

I think I should be able to use '/' in the Output value for dcc.Location.pathname? If I can not, how should I delimit paths or what should I do? The documentation says nothing about this. As far as I know there is no way to attach dcc.Link to the values of components so I wouldn't depend on using the callbacks?

I use quite basic Dash setup with stylesheets and Redis cache. I do not use Page Registry, because I am refactoring someone else's code from tab-oriented single-page app towards url-stateful multi-page app. I am trying to do this without Page Registry as Page Registry would demand more refactoring. Everything works if I use '_' lower dash as "path separator"; it just looks silly.

Screenshots

N/A

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at dcc.Location pathname handling and the callback that returns a slash-delimited path; reproduce the site_tab/site_id case described in the issue. Compare the browser URL with the callback's returned value, and verify that tab-only paths remain unchanged while slash-separated paths are handled correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
43/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.