Skip to content

Commit

Permalink
Merge pull request #219 from rderks88/master
Browse files Browse the repository at this point in the history
  • Loading branch information
marcfil authored May 25, 2022
2 parents bbb3676 + 9365c4c commit cf5341c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Traits/HasTabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,21 @@ protected function panelsWithDefaultLabel(Collection $panels, FieldCollection $f
: $panels;
})
->tap(function ($panels) use ($label): void {
$panels->where('component', 'tabs')->isEmpty() ? $panels->where('component', 'tabs')->first() : $panels->first()->withToolbar();

/**
* There can be no panels
* Preventing ->component or ->withToolbar() on null error
*/
if(!$panels->first()){
return;
}

/**
* Default to ->withToolbar() if the first panel is not a Tabs
* Otherwise, we show the tabs component with the settings configured within it
* This check is necessary in case you ARE using Tabs component, but only for relation as a 2nd or 3rd instance
*/
$panels->first()->component !== 'tabs' ? $panels->first()->withToolbar() : $panels->where('component', 'tabs')->first();
});
}
}

0 comments on commit cf5341c

Please sign in to comment.