-
Notifications
You must be signed in to change notification settings - Fork 28
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
No way of getting out of mention mode with mention prefix that has no matches #681
Comments
Hey @zizhengtai! 👋 I'm here to assist you with any bugs, questions, or contributions you have regarding lexical-beautiful-mentions. Let's squash those bugs together! To address the issue of exiting mention mode when there are no matches, especially with const checkForMentionMatch = useCallback(
(text: string) => {
const queryMatch = checkForMentions(
text,
triggers,
preTriggerChars,
punctuation,
allowSpaces,
);
if (queryMatch) {
const { replaceableString, matchingString } = queryMatch;
const index = replaceableString.lastIndexOf(matchingString);
const trigger =
index === -1
? replaceableString
: replaceableString.substring(0, index) +
replaceableString.substring(index + matchingString.length);
setTrigger(trigger || null);
if (queryMatch.replaceableString) {
return queryMatch;
}
} else {
setTrigger(null);
}
return null;
},
[preTriggerChars, allowSpaces, punctuation, triggers],
); Ensure that the |
@dosu How would the user start typing another mention now that the triggers are set to |
When the |
Given this is the library's internal code I'll wait for a maintainer to answer. |
Is there any update on this? Running into the same issue. |
Sorry for the late reply. I understand the problem, but developing a solution is not straightforward. Currently, the plugin behaves as follows:
The mention mode stays active as long as the text from the trigger character ( The challenge is refining this logic. If no matches are found, mention mode should remain active for corrections, but the menu shouldn’t pop up unnecessarily on each keystroke showing a loading hint. |
I’ve implemented a fix for this issue. Could you please test it and let me know if it solves the problem? Preview: https://lexical-beautiful-mentions-docs-git-fix-8d5159-sodenns-projects.vercel.app/?value=&aspace=true&async=true |
Describe the bug
In apps like Slack, as the user types
@foo...
, as soon as the current input returns an empty result list, the editor exits "mention mode". I.e., now any further characters the user types doesn't trigger the mention search logic and is treated as plain text.With lexical-beautiful-mentions, the editor never exits mention mode even if what the user has entered so far results in zero matches. This is especially problematic when we set
allowSpaces=true
andonSearch={someCustomAsyncFn}
, as some user input can cause the user to get trapped in mention mode without a way to return to plain text mode.To Reproduce
Steps to reproduce the behavior:
@foo bar
Expected behavior
When in mention search mode, as soon as what the user has typed so far results in zero matches, lexical-beautiful-mentions should exit mention mode.
The text was updated successfully, but these errors were encountered: