mirror of
https://github.com/OFFIS-ESC/constellation-analyzer
synced 2026-01-27 07:43:41 +00:00
fix: update group minimize/maximize button label in real-time
The group property panel's minimize/maximize button label was not updating after clicking because it relied on the selectedGroup prop passed from the parent, which was set once on selection and never updated when the group's minimized state changed in the store. Changes: - Added currentGroup lookup from the store's groups array - Use currentGroup (from store) for minimized state checks - Button label now reflects the actual current state This ensures the button always shows the correct action based on the group's actual minimized state in the store, not the stale prop value. Fixes the issue where clicking "Minimize Group" would minimize the group visually but the button would still say "Minimize Group" instead of changing to "Maximize Group". 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
1059c05242
commit
d03be68860
1 changed files with 8 additions and 5 deletions
|
|
@ -39,6 +39,9 @@ const GroupEditorPanel = ({ selectedGroup, onClose }: Props) => {
|
|||
const { confirm, ConfirmDialogComponent } = useConfirm();
|
||||
const reactFlowNodes = useNodes();
|
||||
|
||||
// Get the current group from store to ensure we have the latest state
|
||||
const currentGroup = groups.find(g => g.id === selectedGroup.id) || selectedGroup;
|
||||
|
||||
const [label, setLabel] = useState(selectedGroup.data.label);
|
||||
const [description, setDescription] = useState(selectedGroup.data.description || '');
|
||||
const [color, setColor] = useState(selectedGroup.data.color);
|
||||
|
|
@ -245,12 +248,12 @@ const GroupEditorPanel = ({ selectedGroup, onClose }: Props) => {
|
|||
<button
|
||||
onClick={() => {
|
||||
// Sync current React Flow dimensions before toggling
|
||||
if (!selectedGroup.data.minimized) {
|
||||
if (!currentGroup.data.minimized) {
|
||||
// When minimizing, update the store with current dimensions first
|
||||
const currentNode = reactFlowNodes.find((n) => n.id === selectedGroup.id);
|
||||
const currentNode = reactFlowNodes.find((n) => n.id === currentGroup.id);
|
||||
if (currentNode && currentNode.width && currentNode.height) {
|
||||
setGroups(groups.map((g) =>
|
||||
g.id === selectedGroup.id
|
||||
g.id === currentGroup.id
|
||||
? { ...g, width: currentNode.width, height: currentNode.height }
|
||||
: g
|
||||
));
|
||||
|
|
@ -258,12 +261,12 @@ const GroupEditorPanel = ({ selectedGroup, onClose }: Props) => {
|
|||
}
|
||||
// Use setTimeout to ensure store update completes before toggle
|
||||
setTimeout(() => {
|
||||
toggleGroupMinimized(selectedGroup.id);
|
||||
toggleGroupMinimized(currentGroup.id);
|
||||
}, 0);
|
||||
}}
|
||||
className="w-full px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50 rounded hover:bg-gray-100 transition-colors flex items-center justify-center space-x-2"
|
||||
>
|
||||
{selectedGroup.data.minimized ? (
|
||||
{currentGroup.data.minimized ? (
|
||||
<>
|
||||
<MaximizeIcon fontSize="small" />
|
||||
<span>Maximize Group</span>
|
||||
|
|
|
|||
Loading…
Reference in a new issue