-
Notifications
You must be signed in to change notification settings - Fork 35
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
🐞 - When input is narrow and value doesn't fit into input, setSelectionRange don't scroll to cursor when typing #917
Comments
Checked in [email protected], bug is not reproducible there |
Thank for your for research ❤️ At the first glance, we can use element.addEventListener('input', () => {
/**
* No need to execute it everytime on EVERY input event.
* We need to find a smart way to calculate if cursor is inside overflown area.
* And do something like this:
* ```
* if (isCursorHidden & notSafari & notSomethingElse) {
* element.scrollTo(fixedInput.scrollWidth, 0);
* }
* ```
*/
element.scrollTo(fixedInput.scrollWidth, 0);
}); Learn more: https://stackblitz.com/edit/maskito-bug-scroll-in-small-textfield This solution could become rather controversial and even cause some issues. |
@nsbarsukov, thanks for possible solution, but it looks like we need to calculate width of text that is before cursor, with applied font and font-size to calculate that cursor is hidden, and to understand where should we scroll. cause here the examples when we also can type symbols in hidden area. | symbol means cursor position
we can achieve that by using something like this i didn't found any ways to solve problem without rendering the actual substring somewhere outside of input, but with the same styles |
Haven't looked into it yet, but it looks like the same issue: |
yeah, solution from link is actually what i did in codesandbox example, i found another method, that mentioned in the stackoverflow page you mentioned, which we can use without having special container for calculating width of value before cursor. But it looks a bit complicated |
Which package(s) are the source of the bug?
@maskito/core
Playground Link
https://codesandbox.io/p/sandbox/quiet-wildflower-6ffc5y?file=%2Fsrc%2FApp.tsx%3A58%2C23
Description
Maskito version
1.9.0
Which browsers have you used?
Which operating systems have you used?
The text was updated successfully, but these errors were encountered: