Skip to content

Commit 89989ba

Browse files
authored
Merge pull request #336 from dnum-mi/fix/bug-with-nuxt-link
fix: 🐛 Utilise toujours router-link pour les liens internes
2 parents a157f33 + 198d84b commit 89989ba

28 files changed

+33
-92
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@laruiss/vue-dsfr",
3-
"version": "1.0.0-beta.35",
3+
"version": "1.0.0-beta.53",
44
"files": [
55
"dist",
66
"types",

rollup.config.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ const postcssPlugins = [
3030
const baseOutput = {
3131
globals: {
3232
vue: 'vue',
33-
'oh-vue-icons': 'VIcon',
34-
'oh-vue-icons/icons': 'oh-vue-icons/icons',
35-
'oh-vue-icons/icons/ri/index.js': 'oh-vue-icons/icons/ri/index.js',
36-
'vue-router': 'vue-router',
37-
'focus-trap': 'focus-trap',
38-
'focus-trap-vue': 'focus-trap-vue',
3933
},
4034
}
4135

src/components/DsfrBreadcrumb/DsfrBreadcrumb.vue

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ export default defineComponent({
2727
hideButton: false,
2828
}
2929
},
30-
31-
computed: {
32-
linkComponent () {
33-
return '$nuxt' in this ? 'nuxt-link' : 'router-link'
34-
},
35-
},
3630
})
3731
</script>
3832

@@ -64,7 +58,7 @@ export default defineComponent({
6458
:data-testid="`lis`"
6559
>
6660
<component
67-
:is="linkComponent"
61+
:is="'router-link'"
6862
v-if="link.to"
6963
class="fr-breadcrumb__link"
7064
:to="link.to"

src/components/DsfrCard/DsfrCard.vue

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ export default defineComponent({
3333
horizontal: Boolean,
3434
},
3535
36-
computed: {
37-
linkComponent () {
38-
return '$nuxt' in this ? 'nuxt-link' : 'router-link'
39-
},
40-
},
41-
4236
methods: {
4337
goToTargetLink () {
4438
this.$refs.title.querySelector('.fr-card__link').click()
@@ -59,15 +53,14 @@ export default defineComponent({
5953
ref="title"
6054
class="fr-card__title"
6155
>
62-
<component
63-
:is="linkComponent"
56+
<router-link
6457
:to="link"
6558
class="fr-card__link"
6659
data-testid="card-link"
6760
@click="$event.stopPropagation()"
6861
>
6962
{{ title }}
70-
</component>
63+
</router-link>
7164
</h4>
7265
<p class="fr-card__desc">
7366
{{ description }}

src/components/DsfrConsent/DsfrConsent.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@ export default defineComponent({
1717
isExternalLink () {
1818
return typeof this.url === 'string' && this.url.startsWith('http')
1919
},
20-
linkComponent () {
21-
return '$nuxt' in this ? 'nuxt-link' : 'router-link'
22-
},
2320
is () {
24-
return this.url ? (this.isExternalLink ? 'a' : this.linkComponent) : 'a'
21+
return this.url ? (this.isExternalLink ? 'a' : 'router-link') : 'a'
2522
},
2623
linkProps () {
2724
return { [this.isExternalLink ? 'href' : 'to']: this.url }

src/components/DsfrFooter/DsfrFooter.vue

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ export default defineComponent({
110110
...this.afterMandatoryLinks,
111111
]
112112
},
113-
linkComponent () {
114-
return '$nuxt' in this ? 'nuxt-link' : 'router-link'
115-
},
116113
isWithSlotLinkLists () {
117114
return this.$slots['footer-link-lists']?.().length
118115
},
@@ -143,15 +140,14 @@ export default defineComponent({
143140
<div class="fr-container">
144141
<div class="fr-footer__body">
145142
<div class="fr-footer__brand fr-enlarge-link">
146-
<component
147-
:is="linkComponent"
143+
<router-link
148144
:to="homeLink"
149145
title="Retour à l’accueil"
150146
>
151147
<DsfrLogo
152148
:logo-text="logoText"
153149
/>
154-
</component>
150+
</router-link>
155151
</div>
156152
<div class="fr-footer__content">
157153
<p
@@ -189,14 +185,13 @@ export default defineComponent({
189185
:key="index"
190186
class="fr-footer__bottom-item"
191187
>
192-
<component
193-
:is="linkComponent"
188+
<router-link
194189
class="fr-footer__bottom-link"
195190
:to="link.to"
196191
:data-testid="link.to"
197192
>
198193
{{ link.label }}
199-
</component>
194+
</router-link>
200195
</li>
201196
</ul>
202197
<div class="fr-footer__bottom-copy">

src/components/DsfrFooter/DsfrFooterLinkList.vue

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ export default defineComponent({
1414
default: () => [],
1515
},
1616
},
17-
18-
computed: {
19-
linkComponent () {
20-
return '$nuxt' in this ? 'nuxt-link' : 'router-link'
21-
},
22-
},
2317
})
2418
</script>
2519

@@ -38,14 +32,13 @@ export default defineComponent({
3832
class="fr-footer__top-link"
3933
:to="link.to"
4034
>{{ link.label }}</a>
41-
<component
42-
:is="linkComponent"
35+
<router-link
4336
v-else
4437
class="fr-footer__top-link"
4538
:to="link.to"
4639
>
4740
{{ link.label }}
48-
</component>
41+
</router-link>
4942
</li>
5043
</ul>
5144
</div>

src/components/DsfrHeader/DsfrHeader.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default {
4646
control: 'object',
4747
description: `Tableau des liens d’accès rapide, chaque objet contiendra les props suivantes :
4848
- \`label\`: Texte du lien (\`'Notifications'\`, par ex.)
49-
- \`to\`: Chemin ou objet à passer à \`to\` de \`router-link\` ou \`nuxt-link\` (\`'/notification'\` ou \`{ name: 'Notifications' }\` par ex.)
49+
- \`to\`: Chemin ou objet à passer à \`to\` de \`router-link\` (\`'/notification'\` ou \`{ name: 'Notifications' }\` par ex.)
5050
- \`href\`: URL à passer à \`href\` de la balise \`<a>\` (\`'https://systeme-de-design.gouv.fr\` par ex.) **pour un lien externe uniquement**.
5151
- \`icon\` Nom de l’icône [Remix Icon](https://remixicon.com/) (ou toute autre icône de [oh-vue-icons](https://oh-vue-icons.netlify.app/)) à afficher (\`'ri-phone-line'\` par ex.)
5252
- \`iconRight\` Permet de mettre l’icône à droite (si la valeur est \`true\` ou <em>truthy</em> et que \`icon\` est renseigné )

src/components/DsfrHeader/DsfrHeader.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ export default defineComponent({
6060
},
6161
6262
computed: {
63-
linkComponent () {
64-
return '$nuxt' in this ? 'nuxt-link' : 'router-link'
65-
},
6663
isWithSlotOperator () {
6764
return this.$slots.operator?.().length
6865
},
@@ -146,16 +143,15 @@ export default defineComponent({
146143
v-if="serviceTitle"
147144
class="fr-header__service"
148145
>
149-
<component
150-
:is="linkComponent"
146+
<router-link
151147
:to="homeTo"
152148
:title="`Accueil - ${serviceTitle}`"
153149
v-bind="$attrs"
154150
>
155151
<p class="fr-header__service-title">
156152
{{ serviceTitle }}
157153
</p>
158-
</component>
154+
</router-link>
159155
<p
160156
v-if="serviceDescription"
161157
class="fr-header__service-tagline"

src/components/DsfrHeader/DsfrHeaderMenuLink.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default defineComponent({
4343
if (this.button) {
4444
return 'button'
4545
}
46-
return this.isExternalLink ? 'a' : ('$nuxt' in this ? 'nuxt-link' : 'router-link')
46+
return this.isExternalLink ? 'a' : 'router-link'
4747
},
4848
isPathString () {
4949
return typeof this.path === 'string'

0 commit comments

Comments
 (0)