diff --git a/components/TierListManager.tsx b/components/TierListManager.tsx index 6b9025c..04902e0 100644 --- a/components/TierListManager.tsx +++ b/components/TierListManager.tsx @@ -41,18 +41,25 @@ const TierListManager: React.FC = ({initialItemSet, initia useEffect(() => { const state = searchParams.get('state'); - if (state) { - const decodedState = tierCortex.decodeTierStateFromURL(state); - if (decodedState) { - if (decodedState.title) { - setName(decodedState.title); - } - setTiers(decodedState.tiers); - - setUrlLength(pathname.length + state.length + 7); // 7 is the length of "?state=" - } + if (!state) return; + + const decodedState = tierCortex.decodeTierStateFromURL(state); + if (!decodedState) return; + + // Update name if present + if (decodedState.title) { + setName(decodedState.title); } - }, [pathname.length, searchParams, tierCortex]); + + // Updated label positions + const updatedTiers = decodedState.tiers.map(tier => ({ + ...tier, + labelPosition + })); + + setTiers(updatedTiers); + setUrlLength(pathname.length + state.length + 7); // 7 is the length of "?state=" + }, [pathname.length, searchParams, tierCortex, labelPosition]); const handleTiersUpdate = useCallback((updatedTiers: Tier[]) => { previousTiersRef.current = updatedTiers;