Here are a couple places that should be relevant in understanding why this happens: https://github.com/xwiki/xwiki-platform/blob/266441af635f3d7743e5485d9893616eb354ba6f/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/simpleedittoolbar.vm#L73
From a quick look, nothing seems out of the ordinary in the code. I suspect that `unexpectedly`, the links keeps the focus when clicked, and pressing enter just reactivates it. `Enter` when focusing a link is a click.
(PS: this is an action on the page, not navigation, so semantically those should be buttons, but changing them would be way out of scope for this issue...)
Charpentier Lucas on 04/Sep/25 17:33
I can see a few ways to fix this:
Catch and prevent the enter presses from doing anything when focusing the links. Not possible since it would degrade keyboard controls and accessibility of the editor.
Move focus after the added syntax when it's added.
This second option seems to be reasonable. Focus moves should be done carefully because it can easily lead to a confusing UX. Here, it seems not moving focus is what's actually confusing. IMO it's correct to move the focus of the user when clicking one of those "add syntax block" buttons.
Last question: Why is the text focused only when the syntax highlighting is disabled. My guess is that the highlight is done asynchronously, and it means that when clicking a button, the element in the text is generated and focused, but a few frames after, it's replaced by its highlighted version, which is not focused. Checking what's happening here. It will probably help implementing the second idea I proposed above.
This message was sent by Atlassian Jira (v9.3.0#930000-sha1:287aeb6)
If image attachments aren't displayed, see this article.