Skip to content

Fix unexpected behaviour of the cursor #2927

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

Merged
merged 4 commits into from
Jun 2, 2025
Merged

Conversation

rodasarede
Copy link
Contributor

Closes: #2612

Issue: The cursor position in the input field was not maintained correctly after inserting an invalid character in the middle of the word, causing the cursor to jump to the end of that text.

Changes:
State Management: Updated the onChange method to ensure the cursor position is preserved after state updates.
Cursor Position Handling: Added logic to save and restore the cursor position using setTimeout, addressing the issue of cursor jumps.
Debounce Logic: Adjusted the method to handle debounce actions correctly in sequence with state updates.

Additional:
Added tests to verify that the cursor position remains correctly positioned after typing invalid characters in the input field.

Contributor Checklist

  • I have broken down my PR scope into the following TODO tasks
  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

When inserting a non valid character in the middle of a pattern,
the cursor instantly jumps to the end of the word,
instead of staying in that position.
Added also some case tests.
@gvwilson gvwilson self-assigned this Jul 25, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added the feature something new label Aug 13, 2024
@gvwilson gvwilson changed the title Fixes #2612: unexpected behaviour of the cursor Fix unexpected behaviour of the cursor Aug 13, 2024
@gvwilson gvwilson added P2 considered for next cycle fix fixes something broken and removed feature something new labels Aug 13, 2024
@T4rk1n T4rk1n requested review from gvwilson and emilykl as code owners June 2, 2025 12:45
Copy link
Contributor

@T4rk1n T4rk1n left a comment

Choose a reason for hiding this comment

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

💃 Looks good, thank you.

@T4rk1n T4rk1n merged commit 60dce78 into plotly:dev Jun 2, 2025
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix fixes something broken P2 considered for next cycle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cursor jumps to end of dcc.Input when pattern is not satisfied
3 participants