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

use native useId from Vue.js 3.5 when available #3458

Merged
merged 6 commits into from
Sep 9, 2024

Conversation

P4sca1
Copy link

@P4sca1 P4sca1 commented Sep 5, 2024

#3457

Vue 3.5 added a native SSR-safe useId function. This PR updates the code to use that function by default if no custom function has been provided.

Theoretically this is a breaking change, as versions prior to Vue 3.5 are no longer supported.
However, package managers should emit a warning or an error when the peer dependency range is no longer satisfied.

Copy link

vercel bot commented Sep 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
headlessui-react ❌ Failed (Inspect) Sep 6, 2024 9:58am

Copy link

vercel bot commented Sep 5, 2024

@P4sca1 is attempting to deploy a commit to the Tailwind Labs Team on Vercel.

A member of the Team first needs to authorize it.

Relying on Vue 3.5 means that we have to introduce a breaking change and
make a 2.0 release. Instead, `^3.2.0` also matches `3.5.x`. This means
that we can check whether `useId` is available and use it, if not we
fallback to our implementation.
@RobinMalfait
Copy link
Member

Internal note: Vercel previews are currently failing because they are setup for the main branch where playgrounds live in a different location.

@RobinMalfait RobinMalfait changed the title feat: use native useId from Vue.js 3.5 use native useId from Vue.js 3.5 when available Sep 6, 2024
@P4sca1
Copy link
Author

P4sca1 commented Sep 6, 2024

Thank you for the change to keep support for older versions of vue! @RobinMalfait

I am wondering if there is still a use case for providing a custom id generator with versions > 3.5?
Right now it is no longer possible to provide a custom generator when Vue.useId exists.

@RobinMalfait RobinMalfait marked this pull request as ready for review September 6, 2024 17:15
@RobinMalfait
Copy link
Member

@P4sca1 the changes were introduced to prevent a breaking change. Thanks for the initial work on this!

Regarding your question, I think the only real use case for providing custom useId implementations was if our fallback implementation was not good enough. But if you are on a newer version of Vue where the useId hook is available, I don't see an immediate use case for providing a custom implementation.

Worst case, for testing reasons, you could mock the useId at that point for example.

/cc @thecrypticace worked on this initially, so he might have some better insights on this.

@thecrypticace
Copy link
Contributor

thecrypticace commented Sep 6, 2024

I suspect the answer to that question is no. The reason we added support for it in the first place was that Nuxt had its own useId function before Vue did. And the intent on our side was always to migrate to the native useId once it was available.

With Vue v3.5 Nuxt is now using the native useId that's built in so the need for custom useId hooks is probably limited to pre-Vue 3.5 projects: https://github.com/nuxt/nuxt/pull/28285/files#diff-56fa79b2b6b6d55801e7e885441f1ee98891adfbbe7d11844721dcfdc2dc5583

Copy link
Contributor

@thecrypticace thecrypticace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — works in Vue normally + when SSR'd in Nuxt

@RobinMalfait RobinMalfait merged commit d064738 into tailwindlabs:1.x Sep 9, 2024
6 of 8 checks passed
@RobinMalfait
Copy link
Member

Thank you @P4sca1, this has been released in the latest version.

@DamianGlowala
Copy link

What about insiders version?

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.

4 participants