plotly / plotly/dash

allow Custom Wildcard

Open
#1,828 1 comment 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.
I want to create my own custom _Wildcard class such that I don't have to rely on the pre-defined ones for cases where I need extra flexibility.

A use-case I keep coming up to is the following:

STARTSWITH = _Wildcard("STARTSWITH")

@app.callback(
    Output({"type": "row", "index": STARTSWITH}, "hidden"),
    [Input({"type": "collapse-button", "index": STARTSWITH}, "n_clicks")],
    [State({"type": "row", "index": STARTSWITH}, "hidden")]
)
def callback(btn, rows)

This is really just a way to identify a parent-children relationship (1-n) such that when clicking the parent button, the relevant children row components get retrieved at the same time.
This is useful because components can't have the same ID and so not currently easy to do AFAIK.

Describe the solution you'd like
I would like to be able to define a _Wildcard class with my own callable, which would essentially work as a custom comparator, to filter out Dash Components I don't need in a given callback.

Describe alternatives you've considered

  1. I tried using ALL and the context such that I iterate through and update the changed components - this is extremely inefficient as the number of buttons grow (1k+) regardless of callback time complexity - page slows down to unusable levels.
  2. I tried dynamically creating multiple specific callbacks at runtime (~5k) for each combination of components by wrapping a callable which can work on a singular piece of data at a time. This in combination with prevent_initial_update seems to alleviate the performance issues.

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

No files or tests are named in the issue. Start by reviewing the existing wildcard behavior, including ALL and callback context, then determine where a user-defined callable comparator would fit; done means custom _Wildcard instances can filter matching components for the described parent-child callback without requiring thousands of callbacks.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.