Skip to content

Commit

Permalink
fix(ui/tabs): fix match boundary error
Browse files Browse the repository at this point in the history
  • Loading branch information
haoziqaq committed Apr 6, 2022
1 parent 56b7c24 commit 6cb05e0
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions packages/varlet-ui/src/tabs/Tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default defineComponent({
components: { VarSticky },
inheritAttrs: false,
props,
setup(props) {
setup (props) {
const indicatorWidth: Ref<string> = ref('0px')
const indicatorHeight: Ref<string> = ref('0px')
const indicatorX: Ref<string> = ref('0px')
Expand All @@ -86,8 +86,8 @@ export default defineComponent({
return tabList.find(({ name }: TabProvider) => props.active === name.value)
}
const matchIndex = (): TabProvider | undefined => {
return tabList.find(({ index }: TabProvider) => props.active === index.value)
const matchIndex = (activeIndex?: number): TabProvider | undefined => {
return tabList.find(({ index }: TabProvider) => (activeIndex ?? props.active) === index.value)
}
const matchBoundary = (): TabProvider | undefined => {
Expand All @@ -97,13 +97,11 @@ export default defineComponent({
const { active } = props
isNumber(active)
? active > length.value - 1
? call(props['onUpdate:active'], length.value - 1)
: call(props['onUpdate:active'], 0)
: null
return matchIndex()
if (isNumber(active)) {
const activeIndex = active > length.value - 1 ? length.value - 1 : 0
call(props['onUpdate:active'], activeIndex)
return matchIndex(activeIndex)
}
}
const watchScrollable = () => {
Expand Down

0 comments on commit 6cb05e0

Please sign in to comment.