Skip to content
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

Prevent global keydown event when ContentEditable handled ENTER #909

Merged
merged 2 commits into from
Oct 16, 2024

Conversation

nikku
Copy link
Member

@nikku nikku commented Oct 15, 2024

Proposed Changes

This fixes a regression introduced via a6dfc16.

The prior change switched to onKeyDown, which is an synthetic event handler that cannot prevent default (on global clicks).

What we need to prevent default (global) clicks is actual DOM event handling. Quoting from the Inferno documentation 1:

Lower case events will bypass Inferno's event system in favour of
using the native event system supplied by the browser.


The fixed behavior can be inspected via npm start, using the Dish Decision JavaScript field, but also in the fact that the test suite passes (again):

capture he9DAr_optimized

Checklist

To ensure you provided everything we need to look at your PR:

  • Brief textual description of the changes present
  • Visual demo attached
  • Steps to try out present, i.e. using the @bpmn-io/sr tool
  • Related issue linked via Closes {LINK_TO_ISSUE} or Related to {LINK_TO_ISSUE}

@bpmn-io-tasks bpmn-io-tasks bot added the needs review Review pending label Oct 15, 2024
@nikku nikku changed the title fix(shared): prevent global keydown event when ContentEditable handled ENTER Prevent global keydown event when ContentEditable handled ENTER Oct 15, 2024
@nikku
Copy link
Member Author

nikku commented Oct 16, 2024

Rebased on top of fixed develop. Let's not squash things without adjusting to a conventional commit.

CC @jarekdanielak.

This fixes a regression introduced via a6dfc16.

The prior change switched to `onKeyDown`, which is an synthetic
event handler that cannot prevent default (on global clicks).

What we need to prevent default (global) clicks is actual DOM event
handling. Quoting from the Inferno documentation [1]:

> Lower case events will bypass Inferno's event system in favour of
> using the native event system supplied by the browser.

[1]: https://www.infernojs.org/docs/guides/event-handling
@barmac
Copy link
Member

barmac commented Oct 16, 2024

I find it super confusing that Inferno supports both lowercase and camelcase event handlers. Anyway, thanks for fixing this!

@barmac
Copy link
Member

barmac commented Oct 16, 2024

I've added comments which should save us some WTF in the future.

@barmac
Copy link
Member

barmac commented Oct 16, 2024

I've prepared a PR aiming to fix the flaky test causing CI to fail: #910

@nikku
Copy link
Member Author

nikku commented Oct 16, 2024

This still works as expected. The comments are a valuable addition ✔️

@nikku nikku merged commit e9227ec into develop Oct 16, 2024
4 of 6 checks passed
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Oct 16, 2024
@nikku nikku deleted the native-key branch October 16, 2024 12:37
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.

2 participants