react-mentions icon indicating copy to clipboard operation
react-mentions copied to clipboard

Adding long mentions on single input doesn't move input to the end

Open dominikkurbiel opened this issue 3 years ago • 3 comments

Steps to reproduce:

  1. Type long mention in single line input (longer than width of input)

Expected behaviour: Cursor should go automatically to the end of input.

Observed behaviour: We can see only the part of mention and we don't see where the cursor is. We need to click left arrow (or write more) to go to the end of input

https://user-images.githubusercontent.com/22274153/117020476-c57a7000-acf6-11eb-9804-68b4604d2628.mp4

dominikkurbiel avatar May 04 '21 14:05 dominikkurbiel

I have the same issue. Any workaround?

louxinbo avatar Aug 18 '21 03:08 louxinbo

I have the same issue too, this is my solution:

const ref = useRef<HTMLInputElement>(null);

<MentionsInput inputRef={ref} {...yourProps}>
    <Mention
      onAdd={() => {
          setTimeout(() => {
            if (!ref.current) return;
            const end = ref.current.value.length;
            ref.current.setSelectionRange(end, end);
            ref.current.focus();
          }, 0);
        }}
     {...yourProps}
    />
</MentionsInput>

awuuu0716 avatar Jul 01 '22 06:07 awuuu0716