Skip to content

Commit ade98d6

Browse files
committed
code review feedback
1 parent f6dd876 commit ade98d6

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
99

1010
## Fixed
1111
- [#3629](https://github.com/plotly/dash/pull/3629) Fix date pickers not showing date when initially rendered in a hidden container.
12+
- [#3627][(](https://github.com/plotly/dash/pull/3627)) Make dropdowns searchable wheen focused, without requiring to open them first
1213

1314

1415

components/dash-core-components/src/fragments/Dropdown.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,18 @@ const Dropdown = (props: DropdownProps) => {
539539
const firstVal = displayOptions[0].value;
540540
const isSelected =
541541
sanitizedValues.includes(firstVal);
542-
const newSelection = isSelected
543-
? without([firstVal], sanitizedValues)
544-
: append(firstVal, sanitizedValues);
542+
let newSelection;
543+
if (isSelected) {
544+
newSelection = without(
545+
[firstVal],
546+
sanitizedValues
547+
);
548+
} else {
549+
newSelection = append(
550+
firstVal,
551+
sanitizedValues
552+
);
553+
}
545554
updateSelection(newSelection);
546555
}}
547556
ref={searchInputRef}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,11 @@ def update_output(value):
678678
dash_duo.wait_for_text_to_equal("#output", "Selected: Cambodia")
679679

680680
# Type "can" — should filter to only Canada
681-
send_keys("can")
681+
send_keys("c")
682+
sleep(0.1)
683+
send_keys("a")
684+
sleep(0.1)
685+
send_keys("n")
682686
sleep(0.1)
683687
options = dash_duo.find_elements(".dash-dropdown-option")
684688
assert len(options) == 1

0 commit comments

Comments
 (0)