react-native-controlled-mentions
react-native-controlled-mentions copied to clipboard
Trigger suggestions with a button
Firstly, thanks to author for building and maintaining such a great library.
I have a use case which I believe is fairly common: in addition to a user typing a specific char (e.g. @
) to trigger the suggestions menu, the user should also be able to press a button that will add the @
char to the input at the correct position and trigger the suggestions menu. In attempting this I've run into some issues tracking the selection range / cursor position and inserting the @
char in the right place when the user presses the button. In some cases the content added by a user selecting from the suggestions menu - which normally has form @[John Doe](1)
- seems to break traditional tracking of selection, so that a subsequent use of the aforementioned button will insert the @
char somewhere in the middle of the user representation, like @[John Doe@](1)
, instead of after like @[John Doe](1)@
.
This also becomes an issue because when the button is pushed, the input loses focus, so we need to refocus the input with the cursor at the correct position. I believe solving the above problem would help with this issue, since we'd know the correct cursor position.
I'm trying to work through this now and will drop updates here, but in the meantime I'm curious if other folks have attempted this and what their findings / strategy was. Thanks!
would love to see this feature as well
Thanks for your feedbacks!
You can check my suggestion of the issue here: https://github.com/dabakovich/react-native-controlled-mentions/blob/3.0.0-feat-add-useful-changes-to-the-use-mentions-hook/example/mentions-functional-component-with-triggerable-button.tsx
Those updates will be included in the next v3 release.
Please, install alpha
release to check it by yourself now:
yarn add react-native-controlled-mentions@alpha
// or
npm install --save react-native-controlled-mentions@alpha
Hi everyone has this been implemented in the current version or i should still use the alpha version ?