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

Long input text doesn't line up with hint #761

Open
orassayag opened this issue Feb 11, 2023 · 5 comments
Open

Long input text doesn't line up with hint #761

orassayag opened this issue Feb 11, 2023 · 5 comments
Labels

Comments

@orassayag
Copy link

orassayag commented Feb 11, 2023

Version

Steps to reproduce

  1. Go to https://codesandbox.io/s/nostalgic-payne-n4y9e6
  2. Start type "Alabama-Alabama-Alabama"
  3. Text is blurry in the end.
  4. If you don't get it, just type "Alabama-Alabama-Alabama" and try to delete some characters.

image

Expected Behavior

Text don't blur.

Actual Behavior

Text is blurry.

@orassayag orassayag added the bug label Feb 11, 2023
@ericgio
Copy link
Owner

ericgio commented Feb 21, 2023

Hey @orassayag, thanks for filing this issue! What's happening here is that the text in the main input is overflowing and scrolls within the input, while the hint text behind it stays fixed, creating a blur effect. I'm not totally sure how to go about fixing this problem; there might be a way to sync the selection state of the inputs. I'm open to ideas or PRs to fix this problem.

@ericgio
Copy link
Owner

ericgio commented Feb 21, 2023

I tried a simple test with two inputs and I'm not sure it's possible to sync the behaviors. You can assign the selectionStart and selectionEnd values of one input to the other, but I'm not aware of a way to actually make the values scroll within the input in sync with each other. Unfortunately, the best workaround in this case is probably to just disable the hint.

@orassayag
Copy link
Author

Thanks @ericgio. This is a bug that the QA in our office opened to me and I'm not sure what to tell him. For now I just disable the hint if the characters are bigger than X, but it's not really good. Hope you guys will find a way to solve this. Thanks.

@AlwaysBeCalm
Copy link

@ericgio
can you add an option, a prop to hide the hint/placeholder?

image

@ericgio ericgio changed the title Text is blurry when exceeded the textbox width Long input text doesn't line up with hint Aug 30, 2023
@bryanakitchen
Copy link

bryanakitchen commented Nov 9, 2023

@orassayag and @ericgio - I noticed the problem was that the hint input keeps the value scrolled to the leftmost position, while the main input keeps the value scrolled to the rightmost position. Here's the solution I came up with until a permanent fix is made:

        const hintInput = document.getElementsByClassName('rbt-input-hint')[0];
        const mainInput = document.getElementsByClassName('rbt-input-main')[0];
        if (
          hintInput?.value &&
          mainInput?.scrollWidth > mainInput?.offsetWidth &&
          hintInput?.scrollWidth > hintInput?.offsetWidth
        ) {
          hintInput.scrollLeft = hintInput.scrollWidth;
          hintInput.style.opacity = '0.2';
        } else if (hintInput) {
          hintInput.scrollLeft = hintInput.scrollWidth;
          hintInput.style.opacity = '0.65';
        }

Let me know if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants