-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
i/4665: Added customization of accept mention keys #9751
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
This PR allows integrators to take back the control over Enter and Tab keys when browsing mentions and execute their default actions (new line, focus navigation) instead of committing a mention, which is fine I guess.
-
This PR also allows integrators to use custom keys to commit mentions (such as only Enter but not Tab or "A"), which is also fine.
-
It does not solve the problem of integrators who have mentions such as
- "John Doe"
- "John Smith"
and they want their users to be able to type "John[space]" and pick the specific mention, though. Pressing Space will still close the UI without giving the user a chance to browse any further.
I'm not sure this last scenario was really considered in this PR so let's talk it over and define the scope of this PR @mlewand @mateuszzagorski? FYI I'm OK if the last scenario is handled separately because what we have here brings value to the project and we can always iterate.
packages/ckeditor5-mention/tests/manual/mention-custom-commitKeys.js
Outdated
Show resolved
Hide resolved
packages/ckeditor5-mention/tests/manual/mention-custom-commitKeys.md
Outdated
Show resolved
Hide resolved
@@ -1549,7 +1549,7 @@ describe( 'MentionUI', () => { | |||
}; | |||
|
|||
const keyUpEvtData = { | |||
keyCode: keyCodes.arrowdown, | |||
keyCode: keyCodes.arrowup, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a keyDownEvtData
above that's using keyCodes.arrowdown
, and this one is called keyUpEvtData
- and it looked like it should've been using the keyCodes.arrowup
as it makes more sense.
Regarding the scope: related issue focuses on key handling and I see that comments added couple of months later diverged into handling space in mentions (which is #9741). @mateuszzagorski @oleq let's stick to the original scope of this PR as we're running low on time now. |
Suggested merge commit message (convention)
Fix (mention): The mention plugin will now allow users to customize the accept mention keys by adding the
commitKeys
configuration option. Closes #4665.MINOR BREAKING CHANGE (mention): It is now possible to create a custom array of keyCodes that will be used by the editor to commit mentions. If no custom configuration has been added the default one (enter + tab) will be used as it was before.
Additional information
Added manual test, covered with unit tests, and updated API docs with an example of how to use the applied changes.