tailwindlabs / headlessui

Completely unstyled, fully accessible UI components, designed to integrate beautifully with Tailwind CSS.
https://headlessui.com
MIT License
25.53k stars 1.05k forks source link

Vue warn about getters not being side-effect free #2985

Open DamianGlowala opened 6 months ago

DamianGlowala commented 6 months ago

What package within Headless UI are you using?

@headlessui/vue

What version of that package are you using?

insiders

What browser are you using?

Chrome

Reproduction URL

image image

https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free

Describe your issue

Seeing Vue warnings about getters not being side-effect free for what to me seems like a Headless UI component.

wahyubaskara commented 6 months ago

Same issue

faridibin commented 6 months ago

Same Issue, started happening after last update

SummerPaX commented 6 months ago

I have also the same issue with headlessui tabs, and I did some digging.

Its possible that this computed might be one of the culprits, because it modifies the SSRContext.

// packages/@headlessui-vue/src/components/tabs/tabs.ts

let mySSRIndex = computed(() => {
  if (SSRContext.value) {
    let mySSRIndex = SSRContext.value.panels.indexOf(props.id)
    if (mySSRIndex === -1) return SSRContext.value.panels.push(props.id) - 1
    return mySSRIndex
  }

  return -1
})

I don't think its that big of an issue because every computed is only executed twice and has no heavy code, but the warning messages are clogging up my console window.Thanks for doing such great work

m-shum commented 6 months ago

Yup exactly the same issue here – happening for me specifically with the Tabs component of nuxtUI. The console noise is a headache for sure.

MickL commented 6 months ago

I think it helps more to just upvote the issue instead of writing "same issue" :)