Skip to content

RichText: fix backspace for IE - #17256

Merged
talldan merged 1 commit into
masterfrom
fix/ie-backspace
Aug 30, 2019
Merged

talldan merged 1 commit into
masterfrom
fix/ie-backspace

Conversation

@ellatrix

@ellatrix ellatrix commented Aug 29, 2019 •

Copy link
Copy Markdown
Member

Description

Fixes #15945. The approach is as follows: call onInput when selection changes and then content has changed as well. Input always results in a selection change, so it's a good way to detect input in browsers that don't support the input event, such as IE.

How has this been tested?

Screenshots

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@ellatrix
ellatrix requested a review from jasmussen August 29, 2019 14:44
@ellatrix ellatrix added Browser Issues Issues or PRs that are related to browser specific problems [Package] Rich text /packages/rich-text labels Aug 29, 2019

@jasmussen jasmussen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

YAAAASS! You are amazing!

From purely a functional point of view, IE11 is now working as it should! So good. Thank you.

Codewise, it looks like a lot of red. Specifically it looks like it's actually REMOVING an IE fix. Does that mean the old fix was the cause of havoc?

In any case, such nice work. Thank you.

@ellatrix

Copy link
Copy Markdown
Member Author

Sort of. The old fix was introduced in #6667, I've never cared enough about IE so far to have a look at it. What that fix does is mapping the textinput event to input for IE, because IE doesn't support the input event. The problem is that textinput does not fire on deletion. So that fix tries to work around it by using keyup. The problem lies somewhere there. Perhaps the old fix can be fixed, but I don't really like the fix much, I think it might be better to look at selectionchange and see if there's any content change. If there is, call the input handler. The benefit of that is also we are sure that we can update selection and content at the same time, just like the input event. I think this approach makes the most sense... and it works.

@ellatrix

Copy link
Copy Markdown
Member Author

I'll wait to merge until there is a code review as well.

@jasmussen

Copy link
Copy Markdown
Contributor

Forgot to attach the GIF I recorded:

ie11

@talldan talldan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like a good improvement.

@talldan
talldan merged commit c61bacc into master Aug 30, 2019
@talldan
talldan deleted the fix/ie-backspace branch August 30, 2019 07:01
@gziolo gziolo added this to the Gutenberg 6.5 milestone Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Browser Issues Issues or PRs that are related to browser specific problems [Package] Rich text /packages/rich-text

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RichText: IE11: Backspace sets caret to beginning of field

4 participants