Skip to content

Conversation

@microbit-matt-hillsdon
Copy link
Contributor

The basics

The details

Resolves

See RaspberryPiFoundation/blockly-keyboard-experimentation#618
This is a narrower fix than the one on RaspberryPiFoundation/blockly-keyboard-experimentation#619

Proposed Changes

Prevent Enter/Space from propagating from Grid so it is not inappropriately handled by other listeners, e.g. the keyboard navigation plugin.

Reason for Changes

Test Coverage

Documentation

Additional Information

This can cause unexpected interactions with the keyboard navigation plugin and
potentially other listeners.

We also plan to fix keyboard navigation to ignore events during ephemeral
focus.

See RaspberryPiFoundation/blockly-keyboard-experimentation#618
@maribethb
Copy link
Contributor

Can you do the e.stopPropagation inside the click event handler for the grid_item instead? That's what I was originally thinking, but I guess I don't know if that works for stopping the keyboard event too since that event being fired on enter is browser behavior due to being a button.

@microbit-matt-hillsdon
Copy link
Contributor Author

Can you do the e.stopPropagation inside the click event handler for the grid_item instead? That's what I was originally thinking, but I guess I don't know if that works for stopping the keyboard event too since that event being fired on enter is browser behavior due to being a button.

I don't think so because the keydown event (including propagation) happens before the click event.
Demo: https://jsfiddle.net/hsatg5un/

This is part of why I think this change is OK if we want it in Blockly field editors, but it's not really a reasonable ask of all field editors.

@maribethb
Copy link
Contributor

Thanks for the demo, that's unfortunate. That definitely makes sense why we wouldn't want to ask everyone to do it. I'm not sure if we should even do it, but it's probably worth it to make it easier to write custom keyboard shortcuts.

@cpcallen cpcallen merged commit 25ee5a9 into RaspberryPiFoundation:master Jun 30, 2025
10 checks passed
@cpcallen
Copy link
Collaborator

Sorry, I completely forgot that I also needed to hit merge!

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.

3 participants