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

bug: User mention search does not function properly when typing quickly #2403

Open
nireld opened this issue May 28, 2024 · 6 comments
Open
Labels
bug Something isn't working cluster:@mentions cluster:message-input Issues related to message input and its textarea cluster:state-management status:confirmed Described issue has been reproduced by the repo maintainer

Comments

@nireld
Copy link

nireld commented May 28, 2024

Describe the bug

User mention search does not function properly when typing quickly in the message input field.

To Reproduce

Set up the chat client with the following configuration:

<Chat client={client}>
    <Channel channel={channel} Attachment={CustomAttachment}>
        <Window>
            <ChannelHeader />
            <MessageList />
            <MessageInput 
                mentionAllAppUsers={true} 
                doImageUploadRequest={uploadFile} 
                doFileUploadRequest={uploadFile} 
            />
        </Window>
        <Thread />
    </Channel>
</Chat>

Note the use of mentionAllAppUsers={true} in the MessageInput component.

Ensure there are at least 10 users in the GetStream database.

Start mentioning a user by typing '@' followed by the user's name quickly.

Expected Behavior

The mention suggestions should update in real-time as each character is typed, displaying relevant user matches.

Observed Behavior

If the server returns the result after an additional character is typed in the textbox, the result is ignored. This leads to inconsistent or missing mention suggestions.

The specific ignoring line -
https://github.com/GetStream/stream-chat-react/blob/bffcf77469629846a93590e2619917ac698ce24c/src/components/AutoCompleteTextarea/Textarea.jsx#L359C10-L359C11

The issue is related to the debounce mechanism in the queryUsers function. When typing quickly, the debounce causes incomplete text queries to be sent, leading to ignored results.

Attaching video

Screenshare.-.2024-05-28.9_28_27.AM.mp4
@nireld nireld added bug Something isn't working status: unconfirmed labels May 28, 2024
@nireld nireld changed the title bug: bug: User mention search does not function properly when typing quickly May 28, 2024
@MartinCupela
Copy link
Contributor

The reason, why the last typed characters are actually not used to query a new result is that the SDK is waiting, until the previous query finishes. The logic is embedded inside the query function that is throttled on top of that. The problem here, is that the throttle mechanism does not work, because the function is recreated on each new change event. So it seems that the purpose of waiting for the request to finish was to actually protect from the error of too many requests, that would otherwise be returned by the back-end.

@MartinCupela MartinCupela added status:confirmed Described issue has been reproduced by the repo maintainer cluster:state-management cluster:message-input Issues related to message input and its textarea and removed status: unconfirmed labels May 30, 2024
@MartinCupela
Copy link
Contributor

This issue is a symptom of a wider problem. The MessageInput component will need a refactor so that it is not re-rendered multiple times on every key stroke.

@nireld
Copy link
Author

nireld commented May 30, 2024

Well, any workaround for now?

@MartinCupela
Copy link
Contributor

Hey @nireld. Unfortunately we do not have workaround for this at the moment. This is an architectural problem of a monolith component that unnecessarily re-renders. We will discuss the issue with our product team to see, whether we can advance the solution.

@LoyerAmandine
Copy link

Hey @MartinCupela , we're facing the same issue on a larger scale, particularly with user search, which is very critical for us. It's causing a lot of friction as our users are reporting bugs related to this problem. Given that we rely on a chat partner like GetStream to minimize in-house development, this is a major blocker. I've also created a support ticket but haven't received any updates yet. Appreciate your feedback and any progress on this! (request #54638)

@MartinCupela
Copy link
Contributor

Hey @LoyerAmandine , your request seems related to another component. We have replied to your request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cluster:@mentions cluster:message-input Issues related to message input and its textarea cluster:state-management status:confirmed Described issue has been reproduced by the repo maintainer
Projects
None yet
Development

No branches or pull requests

3 participants