Skip to content

Commit 3ef77c5

Browse files
authored
Merge pull request #3799 from AnnMarieW/fix-dropdown-search-crash
fix: dropdown search crash
2 parents ffe259c + d32715c commit 3ef77c5

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
2222
- [#3768](https://github.com/plotly/dash/pull/3768) Improved `Dropdown` search performance for large options lists
2323
- [#3759](https://github.com/plotly/dash/pull/3759) Fix the issue where `Patch` objects cannot be updated via `set_props()` in `websocket` callback. Fix [#3742](https://github.com/plotly/dash/issues/3742)
2424
- [#3789](https://github.com/plotly/dash/pull/3789) Fixed extra wrapper in `DatePickerRange` and `DatePickerSingle` causing styling and layout issues.
25+
- [#3799](https://github.com/plotly/dash/pull/3799) Fixed dropdown crash when filtering large datasets with component-based labels by using stable item keys for virtualized rows.
2526

2627
## [4.2.0rc3] - 2026-05-12
2728

components/dash-core-components/src/utils/optionRendering.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ export const OptionsList = forwardRef<OptionsListHandle, OptionsListProps>(
400400
className="dash-options-list-virtualized"
401401
onItemsRendered={handleItemsRendered}
402402
itemData={itemData}
403+
itemKey={(index, data) =>
404+
String(data.options[index]?.value ?? index)
405+
}
403406
>
404407
{Row}
405408
</VariableSizeList>

components/dash-core-components/tests/integration/dropdown/test_search_value.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,41 @@ def send_key(key):
107107
last_option.click()
108108

109109
dash_duo.wait_for_text_to_equal("#output", "value=opt_100")
110+
111+
112+
def test_ddsv003_dropdown_virtualized_component_label_filtering(dash_duo):
113+
app = Dash(__name__)
114+
115+
options = [
116+
{
117+
"label": html.Div(["Item ", html.Span(f"#{i}")]),
118+
"value": f"item_{i}",
119+
"search": f"item_{i}",
120+
}
121+
for i in range(1, 2000)
122+
]
123+
124+
app.layout = html.Div(
125+
[
126+
dcc.Dropdown(
127+
id="dd",
128+
options=options,
129+
value="item_1",
130+
searchable=True,
131+
clearable=True,
132+
)
133+
]
134+
)
135+
136+
dash_duo.start_server(app)
137+
138+
dropdown = dash_duo.find_element("#dd")
139+
dropdown.click()
140+
141+
search = dash_duo.find_element(".dash-dropdown-search")
142+
143+
# trigger filtering path that used to crash virtualized list
144+
search.send_keys("199")
145+
sleep(0.5)
146+
147+
assert dash_duo.get_logs() == []

0 commit comments

Comments
 (0)