fix: add key prop to RoleEditView to reset state when switching roles
RoleEditView used useState(role.name) for draft state, but React
reuses the component instance when editingRoleId changes, ignoring
the new initial value. Adding key={editingRoleId} forces a remount,
re-initializing all draft state (name, color, permissions) correctly.
This commit is contained in:
@@ -112,6 +112,7 @@ export function RolesPanel({ spaceId }: RolesPanelProps) {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<RoleEditView
|
<RoleEditView
|
||||||
|
key={editingRoleId}
|
||||||
role={role}
|
role={role}
|
||||||
spaceId={spaceId}
|
spaceId={spaceId}
|
||||||
onBack={() => setEditingRoleId(null)}
|
onBack={() => setEditingRoleId(null)}
|
||||||
|
|||||||
Reference in New Issue
Block a user