Dropdown: onMouseDown should be given undefined, not false, when disabled
Author: k3ntakoCreated Jan 21, 2019Updated Dec 27, 2025
Issue
On React Toolbox 2.0.0-beta.13, console prints an error when an option in the Dropdown is disabled:
Warning: Expected `onMouseDown` listener to be a function, instead got `false`.
If you used to conditionally omit it with onMouseDown={condition && value}, pass onMouseDown={condition ? value : undefined} instead.Code
import Dropdown from 'react-toolbox/lib/dropdown/Dropdown';
...
let newLocationOptions = [{
value: "initial", label: "Select a Location", disabled: true
},{
value: "add-new-location", label: "Add New Location"
},{
value: "empty", label: "Your Locations:", disabled: true
}]
...
<Dropdown
key={selectedLocation}
auto={false}
label="Event Location"
onChange={this.locationChangeHandler}
source={newLocationOptions}
value={selectedLocation}
required={true}
/>Fix
In /components/dropdown/Dropdown.js, change
onMouseDown={!item.disabled && this.handleSelect.bind(this, item[valueKey])}to
onMouseDown={item.disabled ? undefined : this.handleSelect.bind(this, item[valueKey])}Source: react-toolbox/react-toolbox