There are 2 comments.
 
 
XWiki Platform / cid:jira-generated-image-avatar-7818b1a2-ae16-48af-b449-ae13a4678719 XWIKI-16306 Open

Syntax Highlighting causes insertions to be copied to a new line each time Enter is pressed in WikiEditor

 
View issue   ยท   Add comment
 

2 comments

 
cid:jira-generated-image-avatar-83220f29-d170-4809-a8ca-e1af214ad076 Charpentier Lucas on 04/Sep/25 17:27
 
I can reproduce this issue on 17.7.0-SNAPSHOT

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...)
 
cid:jira-generated-image-avatar-83220f29-d170-4809-a8ca-e1af214ad076 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.