Skip to content

Conversation

@anushka-codes1
Copy link
Member

Ensure Enter/Space activates Mosaic toolbar and tile buttons even when other handlers prevent default. This adds explicit key handlers to toolbar and tile buttons to trigger click on Enter/Space. Fixes #587.

Copy link
Member

@thet thet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thank you.

Again, tests would be nice, but the setup could be quite tedious so I don't require this.
Oh, we don't have any mosaic JavaScript tests, so tests are obsolete anyways.

@anushka-codes1
Copy link
Member Author

@thet Thank you so much for the appreciation :) Can this PR be merged now?

@petschki petschki self-requested a review November 17, 2025 07:13
Copy link
Member

@petschki petschki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested these changes. Since the elements are not focusable with the keyboard, the events do not get fired (or only in some rare and random cases)

The general keyboard behavior of mosaic layout editor could need some love. I suggest to look at the event intialization here https://github.com/plone/plone.app.mosaic/blob/master/resources/js/mosaic.layout.js#L309 to inject more convenient keyboard evens. Key combinations with Shift or Ctrl would be also cool (for example to access "add" menu on the top right, or save the whole document with "CMD" + "Enter" ... users getting more and more used to that)

Comment on lines +527 to +534
// Ensure keyboard activation (Enter / Space) triggers the same action
btn.addEventListener("keydown", function (ev) {
if (ev.key === "Enter" || ev.key === " ") {
ev.preventDefault();
// trigger the click handler attached above
btn.click();
}
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my tests this event never gets fired, because tile buttons are not accessible right now via keyboard.

Comment on lines +358 to +364
})
// ensure Enter/Space keyboard activation triggers the click handler
.on("keydown", function (ev) {
if (ev.key === "Enter" || ev.key === " ") {
ev.preventDefault();
$(this).trigger("click");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here. My tests didn't fire the event at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accessibility Issue, Keyboard Navigation not possible

3 participants