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 getting Vue dom elements #1610

Merged
merged 2 commits into from Jun 21, 2022
Merged

Conversation

NoelDeMartin
Copy link
Contributor

@NoelDeMartin NoelDeMartin commented Jun 21, 2022

It seems like there is a bug trying to get the dom element from a Vue component. I got this problem trying to use a custom button to open a Menu.

Here's a reproduction of the issue: https://stackblitz.com/edit/vitejs-vite-rgp3jk?file=src/App.vue

I reproduced the error in the playground-vue as well to test my fix.

What I saw debugging the problem in my app is that ref.value is actually a Proxy. That's why doing '$el' in ref.value returns false, but doing ref.value.$el actually works. I guess it has to do with the way that Vue references component instances, but I think this should be a safe refactor.

Possibly related to vuejs/core#6137

@vercel
Copy link

vercel bot commented Jun 21, 2022

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

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Jun 21, 2022

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

Name Status Preview Updated
headlessui-react ✅ Ready (Inspect) Visit Preview Jun 21, 2022 at 9:53PM (UTC)
headlessui-vue ✅ Ready (Inspect) Visit Preview Jun 21, 2022 at 9:53PM (UTC)

@RobinMalfait
Copy link
Collaborator

Hey! Thank you for your PR!
Much appreciated! 🙏

This is odd, this definitely used to work. Thanks for the refactor!

@DrJume
Copy link

DrJume commented Jul 8, 2022

Using in works except with components which use defineExpose without reexposing $el. This is a bug in Vue and will be fixed in an upcoming PR 👍

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.

None yet

3 participants