Skip to content

Commit

Permalink
fix(BaseTabs): default tab detection on before mount
Browse files Browse the repository at this point in the history
  • Loading branch information
stafyniaksacha committed Jan 23, 2024
1 parent 3740d4a commit 0ad76af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 0 additions & 2 deletions .playground/pages/tests/base/tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const selectedTab = ref('team')
>
<div class="w-full max-w-sm">
<BaseTabs
model-value="team"
justify="center"
:tabs="[
{ label: 'Team', value: 'team' },
Expand Down Expand Up @@ -175,7 +174,6 @@ const selectedTab = ref('team')
<div class="w-full max-w-sm">
<BaseTabs
type="box"
model-value="team"
:tabs="[
{
label: 'Team',
Expand Down
10 changes: 9 additions & 1 deletion components/base/BaseTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ const props = withDefaults(
},
)
const [modelValue] = defineModel<string>()
const [modelValue] = defineModel<string>({
default: null,
})
onBeforeMount(() => {
if (modelValue.value === null) {
modelValue.value = props.tabs[0]?.value
}
})
const justify = useNuiDefaultProperty(props, 'BaseTabs', 'justify')
const type = useNuiDefaultProperty(props, 'BaseTabs', 'type')
Expand Down

0 comments on commit 0ad76af

Please sign in to comment.