From eaf863584ddf463b568cc95c7a8506b2c14e8a02 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Tue, 4 Jul 2023 01:51:50 -0700 Subject: [PATCH] Fix RaidCombobox not switching to raid's section The RaidCombobox should always open to the section that contains the current raid, or the middle section if there is no raid selected. There was some spaghetti code, but this should fix it. --- components/raids/RaidCombobox/index.tsx | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/components/raids/RaidCombobox/index.tsx b/components/raids/RaidCombobox/index.tsx index 1142c8c5..3de4b900 100644 --- a/components/raids/RaidCombobox/index.tsx +++ b/components/raids/RaidCombobox/index.tsx @@ -115,29 +115,13 @@ const RaidCombobox = (props: Props) => { sortGroups(appState.raidGroups) }, []) - // Set current raid and section when the component mounts - useEffect(() => { - // if (appState.party.raid) { - // setCurrentRaid(appState.party.raid) - // if (appState.party.raid.group.section > 0) { - // setCurrentSection(appState.party.raid.group.section) - // } else { - // setCurrentSection(1) - // } - // } else if (props.showAllRaidsOption && !currentRaid) { - // setCurrentRaid(allRaidsOption) - // } - }, []) - - // Set current raid and section when the current raid changes + // Set current section when the current raid changes useEffect(() => { + console.log('Raid has changed') if (props.currentRaid) { - setCurrentRaid(props.currentRaid) - if (appState.party.raid && appState.party.raid.group.section > 0) - setCurrentSection(props.currentRaid.group.section) - else setCurrentSection(1) + setCurrentSection(props.currentRaid.group.section) } else { - setCurrentRaid(undefined) + setCurrentSection(1) } }, [props.currentRaid])