[BUG] dcc.Patch() wipes persistence of sibling pattern-matching elements
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 52/100
Línea de trabajo
Comienza ejecutando la aplicación mínima de Dash del issue con Dash 4.4.0; después, sigue cómo dcc.Patch() actualiza children con pattern-matching IDs y cómo se restaura persistence. Se considera terminado cuando añadir un nuevo hermano conserva la persistence local de los inputs existentes con pattern matching, mientras que la persistence no relacionada permanece sin cambios.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Sibling of: https://github.com/plotly/dash/issues/3681
Environment
dash 4.4.0
When patching a new element to list of elements with pattern matched ids, persistence is wiped from all sibling IDs.
Minimal example:
from dash import ALL, Dash, Input, Output, Patch, dcc, html, clientside_callback, callback
app = Dash(__name__)
def make_input(index):
return dcc.Input(
id={"type": "inp", "index": index},
value="initial",
persistence=True,
persistence_type="local",
)
app.layout = html.Div(
[
html.Button("add", id="add"),
html.Button("clear", id="clear"),
html.Div([make_input(0), make_input(1)], id="container"),
html.Div(id="display"),
html.Pre(id="storage"),
dcc.Interval(id="local_storage_poll", interval=250),
dcc.Input("Hello, I don't wipe", id='non-pattern-matching-id', persistence=True, persistence_type='local')
]
)
@callback(
Output("container", "children"),
Input("add", "n_clicks"),
prevent_initial_call=True,
)
def add_input(n):
patch = Patch()
patch.append(make_input(n + 1))
return patch
@callback(Output("display", "children"), Input({"type": "inp", "index": ALL}, "value"))
def show(values):
return "|".join(values)
# Debug info, show local storage to make it easier to noticed when it's wiped
clientside_callback(
"""
function display_persisted_vals() {
return Object.keys(window.localStorage)
.filter(k => k.startsWith('_dash_persistence.'))
.map(k => k + ' = ' + window.localStorage.getItem(k))
.join('\\n') || '(nothing persisted)';
}
""",
Output("storage", "children"),
Input("local_storage_poll", "n_intervals"),
)
# Debug helper, clear local storage to do a clean test
# (helpful after the fix when the storage doesn't wipe constantly, lol)
clientside_callback(
"""
function clear_persistence() {
Object.keys(window.localStorage)
.filter(k => k.startsWith('_dash_persistence.'))
.forEach(k => window.localStorage.removeItem(k));
window.location.reload();
return window.dash_clientside.no_update;
}
""",
Output("clear", "n_clicks"),
Input("clear", "n_clicks"),
prevent_initial_call=True,
)
if __name__ == "__main__":
app.run(debug=True)
Here is a run of the minimal example app
Persistence works without a patch.
When a patch is applied persistence is wiped from siblings, but not from unrelated elements.
- Lenguaje dominante
- Python
- Estrellas
- 24.4k
- Forks
- 2.3k
- Merge medio
- 1 d 21 h
- PR fusionados (30 d)
- 19
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de plotly/dash
-
good first issue P3 size: 1 task
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
enhancement P2 size: 5
Dificultad 5/5 Más de una semana Aptitud para principiantes 45/100
-
enhancement P3 size: 10+
-
P2 size: 1 task
-
enhancement P3 size: 1
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
Todos los issues de plotly/dash
Issues similares
-
essnmx good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
-
[Feature] 奇物选择添加优先级 Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
syfoud/Simulated_Scepter#174 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Giskard-AI/giskard-oss#2840 · 1 comentario ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Abiertoarea: repo bug perceived difficulty: 2
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
yeti-platform/yeti#1380 ·