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

[Bug Report][3.5.6] v-list-item initialized with an empty "to" property stays without an href #19300

Closed
charlesg99 opened this issue Feb 28, 2024 · 4 comments · Fixed by #19386

Comments

@charlesg99
Copy link

Environment

Vuetify Version: 3.5.6
Vue Version: 3.4.21
Browsers: Chrome 122.0.0.0
OS: Linux x86_64

Steps to reproduce

When using a nav v-list-item, if it is initialized with an empty "to" prop, changing its value doesn't add the associated href on the element a.v-list-item--link.

To reproduce in the repro link:

  • Try to click on "bar" (element has no pointer cursor here)
  • Click on the "Toggle to" button
  • Try to click on "bar" (element now has a pointer cursor)
  • Check the a.v-list-item html, no href attribute

Expected Behavior

The href gets added to the anchor a.v-list-item--link

Actual Behavior

The href isn't added to the anchor

Reproduction Link

https://jsfiddle.net/edx3rac5/

Other comments

I did the same test using only the vue-router and it "works" as expected: https://jsfiddle.net/b9782hej/, although with vue-router the anchor starts with an href attribute even if the "to" value is an empty string.

Note that the exact behavior I'm looking for is exactly what vuetify does (non clickble link if no "to" value), the only problem is the href not being added.

Also, if the v-list-item is first created with a valid "to" value (in the repro link, set the initial "showTo" value to "true"), and then the "to" value is removed, the behavior is correct (could be a workaround).

@Antti-Palola
Copy link
Contributor

Antti-Palola commented Mar 12, 2024

The problem seems to be in non reactive link prop of useLink used by cards and list items when using the to property.
https://github.com/vuetifyjs/vuetify/blob/master/packages/vuetify/src/composables/router.tsx

Antti-Palola added a commit to Quanscient-Public/vuetify that referenced this issue Mar 12, 2024
If for example VCard to prop is evaluated as undefined and
then changed, the changes were not be propagated to the href.

fixes vuetifyjs#19300
Antti-Palola added a commit to Quanscient-Public/vuetify that referenced this issue Mar 12, 2024
If for example VCard to prop is evaluated as undefined and
then changed, the changes were not be propagated to the href.

fixes vuetifyjs#19300
Antti-Palola added a commit to Quanscient-Public/vuetify that referenced this issue Mar 12, 2024
If for example VCard or VListItem `to` prop is evaluated as undefined and
then changed, the changes were not be propagated to the href.

fixes vuetifyjs#19300
Antti-Palola added a commit to Quanscient-Public/vuetify that referenced this issue Mar 12, 2024
If for example VCard or VListItem `to` prop is evaluated as undefined and
then changed, the changes were not be propagated to the href.

fixes vuetifyjs#19300
Antti-Palola added a commit to Quanscient-Public/vuetify that referenced this issue Mar 13, 2024
If for example VCard or VListItem `to` prop is evaluated as undefined and
then changed, the changes were not be propagated to the href.

Breadcrumbs now validates the routes so a fix to tests is required.

fixes vuetifyjs#19300
Antti-Palola added a commit to Quanscient-Public/vuetify that referenced this issue Mar 13, 2024
If for example VCard or VListItem `to` prop is evaluated as undefined and
then changed, the changes were not be propagated to the href.

Breadcrumbs now validates the routes so a fix to tests is required.

fixes vuetifyjs#19300
Antti-Palola added a commit to Quanscient-Public/vuetify that referenced this issue Mar 14, 2024
If for example VCard or VListItem `to` prop is evaluated as undefined and
then changed, the changes were not be propagated to the href.

Breadcrumbs now validates the routes so a fix to tests is required.

fixes vuetifyjs#19300
Antti-Palola added a commit to Quanscient-Public/vuetify that referenced this issue Mar 23, 2024
If for example VCard or VListItem `to` prop is evaluated as undefined and
then changed, the changes were not be propagated to the href.

Breadcrumbs now validates the routes so a fix to tests is required.

fixes vuetifyjs#19300
@realityfilter
Copy link

Could this be reopened please. Under some circumstances the link still looses reactivity. I think the culprit is in

const linkProps = computed(() => ({
    ...props,
    to: props.to ? props.to : {}
  }));

Changing the snippet to this seems to solve the problem:

  const linkProps = computed(() => ({
    ...props,
    to: toRef(() => props.to || {})
  }));

@johnleider
Copy link
Member

Please create a new issue that demonstrates the bug you're experience, thank you!

@realityfilter
Copy link

Created: See #19515
Thanks for the support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants