[BUG] dcc.Patch() wipes persistence of sibling pattern-matching elements
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/100
Hướng nghiên cứu
Bắt đầu bằng cách chạy ứng dụng Dash tối thiểu trong issue với Dash 4.4.0, sau đó theo dõi cách dcc.Patch() cập nhật children với pattern-matching IDs và cách persistence được khôi phục. Được coi là hoàn tất khi việc thêm một sibling mới vẫn giữ nguyên persistence cục bộ cho các inputs hiện có được khớp theo pattern, trong khi persistence không liên quan vẫn không thay đổi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 24.4k
- Fork
- 2.3k
- Merge trung bình
- 1 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 19
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của plotly/dash
-
good first issue P3 size: 1 task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
enhancement P2 size: 5
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
-
enhancement P3 size: 10+
-
P2 size: 1 task
-
enhancement P3 size: 1
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
Issue tương tự
-
essnmx good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
-
[Feature] 奇物选择添加优先级 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
syfoud/Simulated_Scepter#174 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Giskard-AI/giskard-oss#2840 · 1 bình luận ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Đang mởarea: repo bug perceived difficulty: 2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
yeti-platform/yeti#1380 ·