fix(team): fix hooks ordering crash in ToolApprovalSheet
Move useMemo for sourceColor BEFORE the early return (if !current), and restore teamSummary/teamColor/displayName variables that were accidentally removed. Fixes 'Rendered fewer/more hooks' React crash.
This commit is contained in:
parent
ff8b844abe
commit
9f2a7c950a
1 changed files with 7 additions and 9 deletions
|
|
@ -182,22 +182,20 @@ export const ToolApprovalSheet: React.FC = () => {
|
||||||
return () => document.removeEventListener('keydown', handleKeyDown);
|
return () => document.removeEventListener('keydown', handleKeyDown);
|
||||||
}, [handleRespond]);
|
}, [handleRespond]);
|
||||||
|
|
||||||
|
// Resolve teammate color for MemberBadge (when source !== 'lead')
|
||||||
|
const sourceColor = useMemo(() => {
|
||||||
|
if (!current || current.source === 'lead') return undefined;
|
||||||
|
const member = selectedTeamData?.members?.find((m) => m.name === current.source);
|
||||||
|
return member?.color;
|
||||||
|
}, [current, selectedTeamData?.members]);
|
||||||
|
|
||||||
if (!current) return null;
|
if (!current) return null;
|
||||||
|
|
||||||
// Prefer color from the approval itself (always available, even during provisioning),
|
|
||||||
// fall back to teams list, then getTeamColorSet hashes unknown names into TEAMMATE_COLORS.
|
|
||||||
const teamSummary = teams.find((t) => t.teamName === current.teamName);
|
const teamSummary = teams.find((t) => t.teamName === current.teamName);
|
||||||
const colorName = current.teamColor ?? teamSummary?.color ?? current.teamName;
|
const colorName = current.teamColor ?? teamSummary?.color ?? current.teamName;
|
||||||
const teamColor = getTeamColorSet(colorName);
|
const teamColor = getTeamColorSet(colorName);
|
||||||
const displayName = current.teamDisplayName ?? teamSummary?.displayName ?? current.teamName;
|
const displayName = current.teamDisplayName ?? teamSummary?.displayName ?? current.teamName;
|
||||||
|
|
||||||
// Resolve teammate color for MemberBadge (when source !== 'lead')
|
|
||||||
const sourceColor = useMemo(() => {
|
|
||||||
if (current.source === 'lead') return undefined;
|
|
||||||
const member = selectedTeamData?.members?.find((m) => m.name === current.source);
|
|
||||||
return member?.color;
|
|
||||||
}, [current.source, selectedTeamData?.members]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* Backdrop overlay */}
|
{/* Backdrop overlay */}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue