Commit ff9581ff authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(ui): handle tabs component slot vs array prop conflict

The tabs component receives tabs either as an array prop (for simple
label-based tabs) or as a named slot (for custom tab button HTML).
Now it handles both patterns without crashing on count().
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 749c16b3
...@@ -4,13 +4,14 @@ ...@@ -4,13 +4,14 @@
]) ])
@php @php
$alpineId = 'tabs-' . \Illuminate\Support\Str::random(6); $tabsIsArray = is_array($tabs) && count($tabs) > 0;
$defaultTab = $active ?? (count($tabs) > 0 ? array_key_first($tabs) : ''); $defaultTab = $active ?? ($tabsIsArray ? array_key_first($tabs) : '');
@endphp @endphp
<div x-data="{ activeTab: '{{ $defaultTab }}' }" {{ $attributes }}> <div x-data="{ activeTab: '{{ $defaultTab }}' }" {{ $attributes }}>
{{-- Tab Navigation --}} {{-- Tab Navigation --}}
<div class="flex border-b border-[var(--color-border)] overflow-x-auto" role="tablist"> <div class="flex border-b border-[var(--color-border)] overflow-x-auto" role="tablist">
@if($tabsIsArray)
@foreach($tabs as $key => $label) @foreach($tabs as $key => $label)
<button <button
type="button" type="button"
...@@ -25,6 +26,9 @@ $defaultTab = $active ?? (count($tabs) > 0 ? array_key_first($tabs) : ''); ...@@ -25,6 +26,9 @@ $defaultTab = $active ?? (count($tabs) > 0 ? array_key_first($tabs) : '');
{{ $label }} {{ $label }}
</button> </button>
@endforeach @endforeach
@elseif(isset($tabs) && !is_array($tabs))
{{ $tabs }}
@endif
</div> </div>
{{-- Tab Panels --}} {{-- Tab Panels --}}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment