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

[Feature Request] Set caret position on v-text-field #14867

Closed
EvandroLucas opened this issue Mar 24, 2022 · 3 comments
Closed

[Feature Request] Set caret position on v-text-field #14867

EvandroLucas opened this issue Mar 24, 2022 · 3 comments
Labels
duplicate The issue has already been reported

Comments

@EvandroLucas
Copy link

EvandroLucas commented Mar 24, 2022

Problem to solve

Every time I change the variable associated to the v-text-field outside of the component, the caret position is set to the last character. When implementing a wrapper for the component that does some changes to the text itself as the user types, this can muddle any editing the user does mid-string, given that the caret will move itself to the end of the string every time the user hits a key.

Proposed solution

I propose that both an event and a method be created. The event would emit the value of the current caret when it changes, and the method will allow us to set the caret position to any position on the string.

@EvandroLucas
Copy link
Author

To give it a little bit of detail: I'm implementing a wrapper that masks the input as it is typed by the user. The problem is that it requires updating the value passed to the :value prop, and therefore the caret moves to the end of the string when this happens. If I could somehow just prevent the caret from moving, it would already be enough.

@scscgit
Copy link
Contributor

scscgit commented Apr 17, 2022

@KaelWD
Copy link
Member

KaelWD commented Feb 23, 2023

Duplicate of #14935 (just prevent the caret from moving)

Otherwise inputRef.value.selectionStart or useEventListener(document, 'selectionchange', ...

@KaelWD KaelWD closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2023
@KaelWD KaelWD added the duplicate The issue has already been reported label Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate The issue has already been reported
Projects
None yet
Development

No branches or pull requests

3 participants