plotly / plotly/dash

provide Python function returning stringified dict component IDs

Open
#1,625 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Is your feature request related to a problem? Please describe.
When you use pattern matching callbacks and component IDs of type dictionaries, Dash will automatically stringify the IDs before being sent to the browser/DOM.

As far as I know, even if you use the Dash pytest/selenium plugin, if you want to do certain tests on these components (and select them by ID), you would need to find out + assume how the dictionary ID → string ID conversion is done by Dash.

Describe the solution you'd like
A python function callable from somewhere in the dash package which does the conversion, and thereby can safely be used in tests of Dash apps, across dash versions. E.g. something like:

def stringify_id(dict_id: Dict[str, str]) -> str:
    ...


stringify_id({"id": "some_id", "type": "some_type"}) == '{\"id\"\:\"some_id\"\,\"type\"\:\"some_type\"\}'

Additional context
It looks like the conversion internally in Dash today is done on the JavaScript side:
https://github.com/plotly/dash/blob/597dc22c86de97530fb9b0a9bd9f7876bd0d7601/dash-renderer/src/actions/dependencies.js#L111-L123

One way of supporting the use case above would be to add a Python function doing the same stringify logic, and then add new selenium tests to the Dash test suite to ensure the Python-stringify = JavaScript-stringify. Can we do better? Or maybe there is already a solution for this use case (of testing elements with dict IDs) using e.g. dash_duo?

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 with dash-renderer/src/actions/dependencies.js at lines 111-123 to understand the existing browser-side conversion, then inspect the Dash test suite and dash_duo or Selenium coverage mentioned in the issue. Add a callable Python conversion entry point and tests demonstrating that its output matches the JavaScript behavior for dictionary component IDs.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, python
Domain
frontend, testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.