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

[Input] Access to native input via template ref #8113

Closed
1 task done
c01nd01r opened this issue Apr 1, 2025 · 2 comments
Closed
1 task done

[Input] Access to native input via template ref #8113

c01nd01r opened this issue Apr 1, 2025 · 2 comments

Comments

@c01nd01r
Copy link

c01nd01r commented Apr 1, 2025

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

4.2.6

Environment

macos 14.1, Chrome 134, Vue 3.5.13

Reproduction link

Edit on CodeSandbox

Steps to reproduce

Use ref or useTemplateRef to get the native input.

What is expected?

The native input has been accessed.

What is actually happening?

The native input is undefined


Hello!

I tried to get the native input in the Input component using ref or useTemplateRef, but I keep getting undefined.
Moreover, the object I receive in ref and inspect in the dev console seems to reference itself recursively, i.e., inputRef.value.input.input.

How can I correctly get a reference to the native input?

Example in CodeSandbox (a fork from the current documentation):
🔗 CodeSandbox - Ant Design Vue 4.2.6

Log screenshot Image

I also tried this in Ant Design Vue 3.2.20, and the issue doesn’t occur there:
🔗 CodeSandbox - Ant Design Vue 3.2.20

Log screenshot Image
@selicens
Copy link
Member

selicens commented Apr 2, 2025

Image
Just add it at the end .$el

@c01nd01r
Copy link
Author

c01nd01r commented Apr 2, 2025

Thank you so much, it works! A bit not obvious :)

@c01nd01r c01nd01r closed this as completed Apr 2, 2025
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

No branches or pull requests

2 participants