webscopeio / react-textarea-autocomplete

📝 React component implements configurable GitHub's like textarea autocomplete.
MIT License
451 stars 80 forks source link

Prevent autocomplete to change position (set fix position) #152

Open teilzeitgeist opened 5 years ago

teilzeitgeist commented 5 years ago

Is there a way to prevent the autocomplete opening at the top of the textarea?

Because on the one hand the change is annoying and on the other it's in my case buggy: bug

jukben commented 5 years ago

Have you tried to play with boundariesElement prop? Maybe it would be good to allow false option to disable it.

teilzeitgeist commented 5 years ago

Yeah, but unfortunately boundariesElement does not work with (because the autocomplete have to be inside the boundariesElement) or without renderToBody (same behavior you can see in the GIF).

So ... an additional prop will be great!

For example like: autocompletePostionX: auto | left | right autocompletePostionY: auto | top | bottom

jukben commented 5 years ago

Yeah, agree, more like

autocompletePostion={{
    x: "auto | left | right",
    y: "auto | top | bottom"
}}

defaults to auto

What do you think?

teilzeitgeist commented 5 years ago

Sounds perfect to me 😎

jukben commented 5 years ago

I can try tackle it on weekend, but if you have some time for it, you have green light!

teilzeitgeist commented 5 years ago

Sounds great!

I had another case in which the autocomplete has the wrong position (renderToBody is true): image (The bottom of the image is the bottom of the browser window)

Maybe the calculation of the autocomplete position with the new renderToBody prop is not correct.

jukben commented 5 years ago

Ah, sorry about it. I would be great to revisit it then. Although, I think that the proposed prop autocompletePostion makes sense anyway.

teilzeitgeist commented 4 years ago

The wrong calculation of the autcomplete position was my bad 🤦‍♂ .rta__autocomplete was set to display: none; by default ... so the dropdownBounds variable was empty. Now it works.

Anyway the autocompletePostion prop would be great 👍