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: Ensure Reactivity for 'to' Attribute in useLink Composable #20994

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rbgmulmb
Copy link

Description

This PR addresses the following issue:
If a component is initialized without the toattribute, adding the attribute later does not involve the client-side router anymore. Clicking on such a component causes the entire application to reload. This issue is caused by the navigate and route properties returned by the useLink composable not being reactive. This PR adds reactivity to these properties.

Additionally, this PR includes unit tests for the useLink composable to ensure its functionality and correctness.

Markup:

In the current version, clicking on the 'Not Working' card causes the entire application to reload.
In the fixed version, it utilizes the client-side router.

<template>
  <v-app>
    <v-container>
      <v-card
        :to="workingTo"
        color="blue"
        height="100"
        width="200"
      >Working</v-card>
      <v-card
        :to="notWorkingTo"
        color="pink"
        height="100"
        width="200"
      >Not Working</v-card>
    </v-container>
  </v-app>
</template>

<script setup>
  import { ref } from 'vue'

  const workingTo = ref({ name: 'page1' })
  const notWorkingTo = ref(null)

  setTimeout(() => {
    notWorkingTo.value = { name: 'page1' }
  }, 1000)
</script>

@rbgmulmb rbgmulmb changed the title Fix: Ensure Reactivity for 'to' Attribute in useLink Composable fix: Ensure Reactivity for 'to' Attribute in useLink Composable Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant