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

Respect canceled input events #532

merged 3 commits into from Sep 17, 2018


None yet
1 participant

javan commented Sep 14, 2018

Currently, canceling an input event with event.preventDefault() appears to work because it stops the browser's default behavior, but Trix still records the input in its document model and it eventually renders when the next non-canceled input is received.

Example: This is what happens if you cancel keydown for Enter

This change fixes that by simply ignore events that are event.defaultPrevented.

It also introduces a new trix-before-initialize event that's dispatched before Trix installs its event listeners, giving you an opportunity to install yours first.

addEventListener("trix-before-initialize", event => {"keydown", event => {
    if (event.key == "Enter") {

Fixes #469

javan added some commits Feb 2, 2018

Add new trix-before-initialize event
To allow installing event handlers on <trix-editor> before Trix does.

@javan javan merged commit e9e13fb into master Sep 17, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed

@javan javan deleted the respect-canceled-events branch Sep 17, 2018

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