Skip to content

Does OverlayScrollbars React moves caret in inputs? #681

Answered by KingSora
krutoo asked this question in Q&A
Discussion options

You must be logged in to vote

@krutoo This seems to be a "bug" or side effect of chrome.. I couldn't observe any difference in the two inputs inside of Firefox.

Here is what I found out:

OverlayScrollbars measures the viewport container after a mutation. Exactly this measurement causes the caret position to not reset for some reason.

You can simulate this by adding some kind of measuring code at the end of your click listener:

button.addEventListener("click", () => {
  // focus only if input is not focused
  if (document.activeElement !== input) {
    input.focus();
  }

  // change input type
  input.type = input.type === "text" ? "password" : "text";
  button.textContent = input.type === "text" ? "Hide" : "Show";

  /…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@krutoo
Comment options

@KingSora
Comment options

Answer selected by krutoo
@KingSora
Comment options

@krutoo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants