Fix issue with dropdowns crashing

This commit is contained in:
Zerebos 2023-03-13 16:32:51 -04:00
parent 91341958d4
commit c2d1e4505f
2 changed files with 3 additions and 2 deletions

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);

View File

@ -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>