-
Notifications
You must be signed in to change notification settings - Fork 632
Open
Description
Description
When updating the mention data asynchronously in the react-mentions component, the mention suggestions do not update properly. Additionally, pagination is not supported, making it difficult to handle large datasets efficiently.
Steps to Reproduce
- Initialize
MentionsInputwith an async data source. - Fetch mention data dynamically based on user input.
- Observe that the mention list does not update as expected.
- Scroll through the mention list and try to load more data dynamically.
Expected Behavior
- The mention list should update dynamically as new data is fetched.
- Pagination should be supported to fetch additional results when scrolling.
Actual Behavior
- The mention list does not update properly or lags behind, displaying outdated suggestions.
- The component does not support pagination, requiring a full dataset to be loaded at once.
Code Example
<MentionsInput
value={textAreaValue}
allowSpaceInQuery={true}
onChange={onChangeHandler}
id="mentions_input_text_area"
allowSuggestionsAboveCursor={true}
forceSuggestionsAboveCursor={true}
dataTestId="mentions_input_text_area"
placeholder="To mention the accounts use '@'"
style={{ ...mentionsInputWrapperStyle(isFormulaValid) }}
className={isFormulaValid ? 'mentions_input_error' : 'mentions_input'}
customSuggestionsContainer={(item) => (
<CustomSuggestionsContainer
item={item}
key={mentionDataRef.current.length}
onScroll={(event) => {
const { scrollTop, scrollHeight, clientHeight } = event.target;
if (scrollTop + clientHeight >= scrollHeight - 10 && nextUrl) {
fetchMentionData(searchText, (resData) => {
mentionDataRef.current = resData;
}, true);
}
}}
/>
)}
>
<Mention
trigger={'@'}
isLoading={isLoading}
ignoreAccents={true}
appendSpaceOnAdd={true}
data={mentionDataRef.current}
key={mentionDataRef.current.length}
onAdd={(id) => { onItemSelected(id) }}
style={{ ...mentionStyle(isFormulaValid) }}
renderSuggestion={(suggestion, search, highlightedDisplay, index, focused) => (
<CustomRenderSuggestion
highlightedDisplay={highlightedDisplay}
key={mentionDataRef.current.length}
/>
)}
/>
</MentionsInput>
Environment
- Package Version: (^4.4.10)
- React Version: (^18.2.0)
- Browser: (Google Chrome)
Metadata
Metadata
Assignees
Labels
No labels