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

Bug: Input cursor is moved to the end of the text while typing #378

Open
pavelisnear opened this issue Mar 18, 2024 · 1 comment
Open

Bug: Input cursor is moved to the end of the text while typing #378

pavelisnear opened this issue Mar 18, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@pavelisnear
Copy link
Contributor

Using the ComponentSource input and trying to edit the middle of the text leads to the unexpected cursor behaviour.

InputBug.mov
@pavelisnear pavelisnear added the bug Something isn't working label Mar 18, 2024
@andy-haynes
Copy link
Contributor

This is likely happening for all text inputs. Each time a character is entered, the Component in the iframe is invoking its useState setter. This causes a re-render of the outer DOM, which I'm guessing causes the input to lose and reacquire focus.

If the outer application tracked interactions like this, it could potentially intercept the focus disruption and place the cursor in the correct position. I imagine you could do this with focus/blur listeners on text inputs in the outer DOM that can detect or query whether the event happened as a result of a Component re-render.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants