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

implementing hashtags with spaces. How do i stop the Auto completing ive already tried hitting Enter? #177

Open
japrogramer opened this issue Sep 7, 2019 · 5 comments
Labels
needs repro 🙏 This PR needs reproduction example

Comments

@japrogramer
Copy link

Hello I am trying to implement hashtags

                  "#": {
                    allowWhitespace: true,
                    dataProvider: async token => {
                      console.log(token)
                      const names = await client.query({
                          query: GroupAutoSugQuery,
                          variables: { token }
                        }).then( result => {
                          const sug = result.data.groupSug.map(u => ({ name: u.name}))
                          return sug; });

                     return names;
                    },
                    component: GroupItem,
                    output: (item, trigger) => `${trigger}${item.name.replace(/ /g, "_")}`
                  }

but when i type in the textarea something like. ..

#new_pages #New_from_modal #Coco

the console logs this on the last call

coco
new_pages #New_from_modal #Coco

It seems that the tag is sometimes being passed the coco part as a token
but on other parts the whole line ... which i do not want.

But i have to allow white spaces because groups can have white spaces.

@japrogramer
Copy link
Author

was able to work around it with ..

var lastIndex = token.lastIndexOf('#')
var sanitized_token = token.slice(lastIndex + 1)

@japrogramer
Copy link
Author

japrogramer commented Sep 7, 2019

Re-opening .. because i don't think the default behavior makes sense.
Also how can i escape the auto complete functionality .. see after i hit enter .. it keeps trying to complete.

@japrogramer japrogramer reopened this Sep 7, 2019
@japrogramer japrogramer changed the title implementing hashtags with spaces. implementing hashtags with spaces. How do i stop the Auto completing ive already tried hitting Enter? Sep 7, 2019
@japrogramer
Copy link
Author

Perhaps having an exit character to tell the component to stop trying to auto complete.
something like ';'

@jukben
Copy link
Collaborator

jukben commented Sep 9, 2019

Thanks for bug report. Could you please create codesandbox (for example basend on this https://codesandbox.io/s/k34153yp0v) as repro? Expected behavior, actual behavior?🙏

@jukben jukben added the needs repro 🙏 This PR needs reproduction example label Sep 9, 2019
@japrogramer
Copy link
Author

@jukben I have recreated the bug .. https://codesandbox.io/s/reacttextareaautocomplete-tw12d

its the output: and the allowWhitespaces that together create the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro 🙏 This PR needs reproduction example
Projects
None yet
Development

No branches or pull requests

2 participants