Skip to content

Commit

Permalink
Update Dropdown.js (#6797)
Browse files Browse the repository at this point in the history
Prevent "Uncaught TypeError: Cannot read properties of undefined (reading 'findIndex')" error from being thrown when visibleOptions is null or undefined.
  • Loading branch information
elliotspall authored Jun 26, 2024
1 parent 0c155da commit fb7c44b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion components/lib/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ export const Dropdown = React.memo(
const onEditableInputChange = (event) => {
let searchIndex = null;

if (event.target.value) {
if (event.target.value && visibleOptions) {
searchIndex = visibleOptions.findIndex((item) => getOptionLabel(item).toLocaleLowerCase().startsWith(event.target.value.toLocaleLowerCase()));
}

Expand Down

0 comments on commit fb7c44b

Please sign in to comment.