Fix issue with dropdowns crashing
This commit is contained in:
parent
91341958d4
commit
c2d1e4505f
|
@ -79,7 +79,7 @@ function confirmDelete(addon) {
|
|||
export default function AddonList({prefix, type, title, folder, addonList, addonState, onChange, reload, editAddon, deleteAddon}) {
|
||||
const [query, setQuery] = useState("");
|
||||
const [sort, setSort] = useState(getState.bind(null, type, "sort", "name"));
|
||||
const [ascending, setAscending] = useState(getState.bind(null, type, "ascending", "true"));
|
||||
const [ascending, setAscending] = useState(getState.bind(null, type, "ascending", true));
|
||||
const [view, setView] = useState(getState.bind(null, type, "view", "list"));
|
||||
const [, forceUpdate] = useReducer(x => x + 1, 0);
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@ export default function Select({value: initialValue, options, style, onChange})
|
|||
}, [open]);
|
||||
|
||||
|
||||
const selected = options.find(o => o.value == value);
|
||||
// ?? options[0] provides a double failsafe
|
||||
const selected = options.find(o => o.value == value) ?? options[0];
|
||||
const optionComponents = <div className="bd-select-options">
|
||||
{options.map(opt =>
|
||||
<div className={`bd-select-option${selected.value == opt.value ? " selected" : ""}`} onClick={() => change(opt.value)}>{opt.label}</div>
|
||||
|
|
Loading…
Reference in New Issue