Fix issue with dropdowns crashing

This commit is contained in:
2023-03-13 16:32:51 -04:00
parent 77723e55aa
commit 372ce27157
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -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>