->collapsed(function (Livewire $livewire, ?ComponentContainer $item): bool {
// When creating, keep items expanded
if ($livewire->mountedActionName === 'create') {
return false;
}
// For edit mode, check if this specific item is the clicked option
if ($item) {
// Get the raw state from the ComponentContainer
$state = $item->getRawState();
$isClickedOption = $state['is_clicked_option'] ?? false;
// Expand the clicked option (return false), collapse others (return true)
return !$isClickedOption;
}
// Default: collapse items in edit mode
return true;
})
->collapsed(function (Livewire $livewire, ?ComponentContainer $item): bool {
// When creating, keep items expanded
if ($livewire->mountedActionName === 'create') {
return false;
}
// For edit mode, check if this specific item is the clicked option
if ($item) {
// Get the raw state from the ComponentContainer
$state = $item->getRawState();
$isClickedOption = $state['is_clicked_option'] ?? false;
// Expand the clicked option (return false), collapse others (return true)
return !$isClickedOption;
}
// Default: collapse items in edit mode
return true;
})