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

FIO-9144 Fix cursor jump in number component #5859

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

blakekrammes
Copy link
Contributor

@blakekrammes blakekrammes commented Oct 11, 2024

Link to Jira Ticket

https://formio.atlassian.net/browse/FIO-9144

Description

What changed?

There's a function called restoreCaretPosition in Component.js that restores the position of the input caret after a refresh. However, in this case, it was not taking the input value's delimiters into account. It might have to do with the time it takes to update the input mask. This PR changes restoreCaretPosition to use the length of the input value instead of root.currentSelection so that delimiters are included in the setSelection() call.

Why have you chosen this solution?

The input value was already within the scope of the function; this solution doesn't mutate root.currentSelection.

Breaking Changes / Backwards Compatibility

n/a

Dependencies

n/a

How has this PR been tested?

Added test for number component that asserts the correct input selection start (caret/cursor) position after calling restoreCaretPosition on it.

Checklist:

  • I have completed the above PR template
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • My changes include tests that prove my fix is effective (or that my feature works as intended) (singular test)
  • New and existing unit/integration tests pass locally with my changes
  • Any dependent changes have corresponding PRs that are listed above

@blakekrammes blakekrammes force-pushed the FIO-9144-number-input-cursor-jump branch 2 times, most recently from acbf6fa to 5c76cd6 Compare October 11, 2024 22:51
- Use the length of the input value instead of root.currentSelection so that delimiters are included in the length.

- Add test for number component that asserts the correct input selection start (caret/cursor) position.
@blakekrammes blakekrammes force-pushed the FIO-9144-number-input-cursor-jump branch from 5c76cd6 to 2510cbe Compare October 11, 2024 22:52
@brendanbond brendanbond merged commit 6f0fa61 into master Oct 15, 2024
5 checks passed
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.

2 participants