Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: NavigationMenu recursive issue causing crash #197

Merged
merged 1 commit into from
Jul 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions packages/radix-vue/src/NavigationMenu/NavigationMenuViewport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const { primitiveElement, currentElement } = usePrimitiveElement();

const context = inject(NAVIGATION_MENU_INJECTION_KEY);

const content = ref<HTMLElement>();
const size = ref<{ width: number; height: number }>();

const open = computed(() => !!context?.modelValue.value);
Expand All @@ -30,16 +29,14 @@ const viewportContentList = computed(() =>
Array.from(context?.viewportContent.value.values())
);

const isActive = ref(false);
const setRef = (node: VNode) => {
const items = ref<InstanceType<typeof NavigationMenuContentImpl>[]>();
const content = computed(() => {
const activeNode = items.value?.find(
(i) => i?.value === activeContentValue.value
);
// @ts-ignore
isActive.value = activeContentValue.value === node?.value;
if (isActive.value) {
// @ts-ignore
content.value = unrefElement(node);
}
return undefined;
};
return unrefElement(activeNode?.$el);
});

const handleClose = (node: VNode) => {
context!.modelValue.value = "";
Expand Down Expand Up @@ -80,7 +77,7 @@ defineOptions({
<template v-for="node in viewportContentList" :key="node.props?.value">
<Presence :present="activeContentValue === node.props?.value">
<NavigationMenuContentImpl
:ref="setRef"
ref="items"
v-bind="{ ...node.props, ...node.parentProps }"
@escape="handleClose(node)"
>
Expand Down
Loading