Skip to content

Commit

Permalink
fix(Tabs): fixed activation of tabs with keys that are defined but falsy
Browse files Browse the repository at this point in the history
  • Loading branch information
mtorromeo committed Dec 20, 2023
1 parent 5032e41 commit 184349c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/core/src/components/Tabs/Tab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ defineSlots<{
}>();
const instance = getCurrentInstance();
const key = computed(() => instance?.vnode.key ?? Symbol());
const fallbackKey = Symbol();
const key = computed(() => instance?.vnode.key ?? fallbackKey);
const tabs = inject(TabsProvideKey);
useChildrenTracker(TabsKey, key);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/Tabs/Tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ import { watchEffect, nextTick, onMounted, provide, computed, type InjectionKey,
import { useOUIAProps, type OUIAProps } from '../../helpers/ouia';
import AngleLeftIcon from '@vue-patternfly/icons/angle-left-icon';
import AngleRightIcon from '@vue-patternfly/icons/angle-right-icon';
import { useEventListener } from '@vueuse/core';
import { isDefined, useEventListener } from '@vueuse/core';
import { provideChildrenTracker, type ChildrenTrackerInjectionKey } from '../../use';
defineOptions({
Expand Down Expand Up @@ -155,7 +155,7 @@ if (!props.vertical) {
}
watchEffect(() => {
if ((!localActiveKey.value || !tabKeys.find(k => k.value === localActiveKey.value)) && tabKeys.length) {
if ((!isDefined(localActiveKey.value) || !tabKeys.find(k => k.value === localActiveKey.value)) && tabKeys.length) {
localActiveKey.value = tabKeys[0].value;
}
});
Expand Down

0 comments on commit 184349c

Please sign in to comment.