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

Fix erroneous text after native insert #4529

Merged

Conversation

nemanja-tosic
Copy link
Contributor

@nemanja-tosic nemanja-tosic commented Sep 15, 2021

Description

The code was backing out of a native insert if there are ops other than insert_text, but at that point the decision to preventDefault was already made. The PR takes into account the flush as well, and does a prevent default in case a flush has occured.

Issue

Fixes: #4527

Notes

Refactored asNative to record previous state and reset it in a finally clause. A variable is set, so the function should clean up after itself, to put it tersely. Also, captured the previous state of AS_NATIVE, as to account for potential nesting of the calls.

Checks

  • The new code matches the existing patterns and styles.
  • The tests pass with yarn test.
  • The linter passes with yarn lint. (Fix errors with yarn fix.)
  • The relevant examples still work. (Run examples with yarn start.)
  • You've added a changeset if changing functionality. (Add one with yarn changeset add.)

@changeset-bot
Copy link

changeset-bot bot commented Sep 15, 2021

🦋 Changeset detected

Latest commit: f74c63e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
slate-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines +29 to +31
if (!NATIVE_OPERATIONS.get(editor)) {
onFlushed?.()
}
Copy link
Contributor Author

@nemanja-tosic nemanja-tosic Sep 15, 2021

Choose a reason for hiding this comment

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

The important bit, everything else in this method is a refactor (boy scout rule).

Copy link

@churichard churichard left a comment

Choose a reason for hiding this comment

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

Would be great to merge this in 😄

@dylans dylans merged commit bd80a0b into ianstormtaylor:main Sep 19, 2021
@github-actions github-actions bot mentioned this pull request Sep 19, 2021
@clauderic
Copy link
Collaborator

Hey there, looks like there was a regression with deletion of selected fragments in Firefox. I've traced the regression back to this PR:

Firefox.expanded.selection.crash.mp4

This behaviour can be replicated in all versions of Firefox that I tested (I checked on Firefox 92, 91, and 90).

@nemanja-tosic
Copy link
Contributor Author

Hi @clauderic. Are you sure this PR was the cause and not #3888? This PR was trying to fix a bug introduced by #3888.

@clauderic
Copy link
Collaborator

Hey @nemanja-tosic, I'm fairly certain it was this PR yes. The previous commits right up until this PR work fine in Firefox:

Kapture.2021-09-24.at.17.00.56.mp4

This isn't to say that your PR doesn't indeed fix a bug introduced by #3888, but it seems to have caused other regressions.

@nemanja-tosic
Copy link
Contributor Author

That's ok, I'll take a look. There are several problems due to #3888 right now which I'm looking at as well. Thanks!

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.

Text is always being inserted, even when using auto markdown
4 participants