-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { InjectionKey } from 'vue' | ||
|
||
type RegisterNavigationLink = () => () => void | ||
|
||
export const registerNavigationLinkKey: InjectionKey<RegisterNavigationLink> = Symbol('header') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
<script lang="ts" setup> | ||
import { computed } from 'vue' | ||
import { computed, inject } from 'vue' | ||
import { getRandomId } from '../../utils/random-utils' | ||
import VIcon from '../VIcon/VIcon.vue' | ||
import { registerNavigationLinkKey } from '../DsfrHeader/injection-key' | ||
import VIcon from '../VIcon/VIcon.vue' | ||
import type { DsfrNavigationMenuLinkProps } from './DsfrNavigation.types' | ||
export type { DsfrNavigationMenuLinkProps } | ||
|
@@ -27,6 +28,9 @@ const iconProps = computed(() => (dsfrIcon.value || !props.icon) | |
? { scale: defaultScale, name: props.icon } | ||
: { scale: defaultScale, ...((props.icon as Record<string, string>) || {}) }, | ||
) | ||
const useHeader = inject(registerNavigationLinkKey)! | ||
const closeModal = useHeader() | ||
Check failure on line 33 in src/components/DsfrNavigation/DsfrNavigationMenuLink.vue GitHub Actions / Run unit tests and CT testssrc/components/DsfrNavigation/DsfrNavigation.spec.ts > DsfrNavigation > should render navigation menu
Check failure on line 33 in src/components/DsfrNavigation/DsfrNavigationMenuLink.vue GitHub Actions / Run unit tests and CT testssrc/components/DsfrNavigation/DsfrNavigation.spec.ts > DsfrNavigation > should render navigation menu and expand menu on click
Check failure on line 33 in src/components/DsfrNavigation/DsfrNavigationMenuLink.vue GitHub Actions / Run unit tests and CT testssrc/components/DsfrNavigation/DsfrNavigationMegaMenu.spec.ts > DsfrNavigationMegaMenu > should render a navigation mega menu
Check failure on line 33 in src/components/DsfrNavigation/DsfrNavigationMenuLink.vue GitHub Actions / Run unit tests and CT testssrc/components/DsfrNavigation/DsfrNavigationMegaMenuCategory.spec.ts > DsfrNavigationMegaMenuCategory > should render a navigation mega menu
Check failure on line 33 in src/components/DsfrNavigation/DsfrNavigationMenuLink.vue GitHub Actions / Run unit tests and CT testssrc/components/DsfrNavigation/DsfrNavigationMenu.spec.ts > DsfrNavigationMenu > should render a navigation mega menu
Check failure on line 33 in src/components/DsfrNavigation/DsfrNavigationMenuLink.vue GitHub Actions / Run unit tests and CT testssrc/components/DsfrNavigation/DsfrNavigationMenuLink.spec.ts > DsfrNavigationMenuLink > should render a navigation menu link (internal) with icon
Check failure on line 33 in src/components/DsfrNavigation/DsfrNavigationMenuLink.vue GitHub Actions / Run unit tests and CT testssrc/components/DsfrNavigation/DsfrNavigationMenuLink.spec.ts > DsfrNavigationMenuLink > should render a navigation menu link (internal) without icon
|
||
</script> | ||
|
||
<template> | ||
|
@@ -35,8 +39,7 @@ const iconProps = computed(() => (dsfrIcon.value || !props.icon) | |
class="fr-nav__link" | ||
data-testid="nav-external-link" | ||
:href="(to as string)" | ||
@click="$emit('toggleId', id)" | ||
@click.stop="onClick($event)" | ||
@click="$emit('toggleId', id); onClick($event)" | ||
> | ||
{{ text }} | ||
</a> | ||
|
@@ -48,8 +51,7 @@ const iconProps = computed(() => (dsfrIcon.value || !props.icon) | |
:class="{ | ||
[String(icon)]: dsfrIcon, | ||
}" | ||
@click="$emit('toggleId', id)" | ||
@click.stop="onClick($event)" | ||
@click="closeModal(); $emit('toggleId', id); onClick?.($event)" | ||
> | ||
<VIcon | ||
v-if="icon && iconProps" | ||
|