vuetify icon indicating copy to clipboard operation
vuetify copied to clipboard

[Bug Report][3.4.3] VTabs color prop not working with href

Open Larsluph opened this issue 2 years ago • 12 comments

Environment

Vuetify Version: 3.4.3 Vue Version: 3.3.4 Browsers: Edge 119.0.0.0 OS: Windows 10

Steps to reproduce

  1. Create a v-tabs component with a color prop
  2. Create some v-tab inside it with and without href

Expected Behavior

Color class is injected regardless of the href attribute

Actual Behavior

Text stays white and color class isn't injected

Reproduction Link

https://play.vuetifyjs.com/#...

Larsluph avatar Nov 23 '23 21:11 Larsluph

Set class or color for tab? https://play.vuetifyjs.com/#eNptUdFKwzAU/ZVLFKqwteh8kLEpgoLPvviwDpamty4sbUKSlsnYv3vTbK4Vn5J7zsnp6T2rA3NWZC/GpF2LbM4WHmujuMenvAFYdFNuTH/tB6Ebz2WD9gT1oOeFg25a6xLVMmc0fmCVMxBaaUuAxZKm4oteR8BYWXP7nbNfl7PPZQZyrHo1wSAbCF955Z7nbCiad1y1GFV/GI97/y+xtVgRId07Xd4aXigs4Rk2V9n1gdTHDcyhbUqs6Ecp+fCtUNy5YEre00JxsRvy2WUrWVwLAYNFiS2KXaH3g2WNQtCWFC96/FP6LYSghJ1tg+m4gIDEfhbZoDcanbDSeHDo21ifrI22Hg5AnnCEyuoaEqo8iQnJ13kYr2QZtDcVVw5vL5pY74lMaLpLiB3xfU+kWEV6AuG8T9YhZgxGkdhxwmbpLH1k4XxIZ2z9Az1ayZk=https://play.vuetifyjs.com/#eNptUdFKwzAU/ZVLFKqwteh8kLEpgoLPvviwDpamty4sbUKSlsnYv3vTbK4Vn5J7zsnp6T2rA3NWZC/GpF2LbM4WHmujuMenvAFYdFNuTH/tB6Ebz2WD9gT1oOeFg25a6xLVMmc0fmCVMxBaaUuAxZKm4oteR8BYWXP7nbNfl7PPZQZyrHo1wSAbCF955Z7nbCiad1y1GFV/GI97/y+xtVgRId07Xd4aXigs4Rk2V9n1gdTHDcyhbUqs6Ecp+fCtUNy5YEre00JxsRvy2WUrWVwLAYNFiS2KXaH3g2WNQtCWFC96/FP6LYSghJ1tg+m4gIDEfhbZoDcanbDSeHDo21ifrI22Hg5AnnCEyuoaEqo8iQnJ13kYr2QZtDcVVw5vL5pY74lMaLpLiB3xfU+kWEV6AuG8T9YhZgxGkdhxwmbpLH1k4XxIZ2z9Az1ayZk=

websitevirtuoso avatar Nov 25 '23 02:11 websitevirtuoso

It seems your link is invalid, I got the following exception: DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded. image

Anyway, the only color I can set on the v-tab element is the slider-color which doesn't change the text color. And for the class I did that as a workaround. I detect if the tab is active and apply the color class if needed: :class="{ 'text-accent': innerTabV === value }"

Larsluph avatar Nov 25 '23 08:11 Larsluph

image

websitevirtuoso avatar Nov 25 '23 21:11 websitevirtuoso

What I want is change the color of the focused tab. When not using the href attribute, the color prop does exactly that. If I want to use the href prop with that behavior, I need to use a workaround to apply the color class only if the tab is the only currently focused.

Larsluph avatar Nov 26 '23 15:11 Larsluph

After some research I found that the following snippet controls whether to inject color classes or not. By playing with link.isLink.value, this in fact enabled the color prop with the href attribute. I assume this is an expected behavior given that it is present on a more generic component (namely VBtn).

https://github.com/vuetifyjs/vuetify/blob/b50e9ad559fc4d958ff2f6ed7f873c3efcd592af/packages/vuetify/src/components/VBtn/VBtn.tsx#L161-L164

Larsluph avatar Nov 26 '23 16:11 Larsluph

we have prop selected-color or selected-class check it out

websitevirtuoso avatar Nov 26 '23 19:11 websitevirtuoso

There's no such thing as selected-color prop in the documentation. However the color prop explicitly tells us that it should paint the selected tab to that color, which is not when using the href attribute. The selected-class prop may be a better workaround but that's still a bug for me.

https://vuetifyjs.com/en/api/v-tabs/#props-color image

Larsluph avatar Nov 26 '23 20:11 Larsluph

I tried to help and everything works for me

websitevirtuoso avatar Nov 26 '23 20:11 websitevirtuoso

Thanks for your help, I found a workaround for that issue. I just wanted to report that the behavior described in the docs is not working while using the href attribute.

Larsluph avatar Nov 26 '23 21:11 Larsluph

The problem is this uses link.isActive even though that only applies for :to links: https://github.com/vuetifyjs/vuetify/blob/72f33dcd84ef3a3799ec1312a5eaa42e320b3e92/packages/vuetify/src/components/VBtn/VBtn.tsx#L128

KaelWD avatar Jun 10 '24 12:06 KaelWD

Using the :to prop instead of :href does apply color as expected.

Larsluph avatar Aug 03 '24 00:08 Larsluph

Yeah cool it's still a bug though.

KaelWD avatar Aug 16 '24 07:08 KaelWD

I added a comment here: https://github.com/vuetifyjs/vuetify/issues/20348#issuecomment-2740449939

They might be connected.

david2242 avatar Mar 20 '25 13:03 david2242