Skip to content

priorFocusedElem.focus() throws in IE11 #12763

Closed

Description

@kristiandupont

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
We have an onClick handler on an SVG element. The handler sets a state property that causes the element to be hidden (via CSS). This makes IE11 throw on this line:
https://github.com/facebook/react/blob/52eb59dda2eb0d9afe3a18aacd6142c1d2f7ee25/packages/react-dom/src/client/ReactInputSelection.js#L72

It seems that #11800 removed a try/catch protection for this.

I am working around the problem by stubbing focus like this:

if (typeof SVGElement.prototype.focus === 'undefined') { SVGElement.prototype.focus = function () {}; }

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

Worked in 16.2.2

Activity

  1. jquense commented on May 8, 2018

    @jquense
    Contributor

    Can you put together a reproduction demonstrating the issue?

  2. gaearon commented on May 8, 2018

    @gaearon
    Collaborator

    In the meantime please feel free to send a PR adding try-catch with an explanation comment

  3. ThaddeusJiang commented on Jun 7, 2018

    @ThaddeusJiang
    Contributor

    I hava a same problem.

    React 16.4

  4. gaearon commented on Jun 7, 2018

    @gaearon
    Collaborator

    @ThaddeusJiang That doesn't help us in any way. It will help us if you provide a reproducing case. Thanks.

  5. gaearon commented on Jun 7, 2018

    @gaearon
    Collaborator

    Can somebody with IE11 figure out if:

    • SVGs don't have focus() in IE11
    • If their focus() call throws on hidden elements
    • Something else?
  6. kristiandupont commented on Jun 7, 2018

    @kristiandupont
    Author

    Sorry, I forgot about this because my workaround solved it for me. I will make a PR and try to figure out if it applies to other classes as well

  7. gaearon commented on Jun 7, 2018

    @gaearon
    Collaborator

    Thanks!

  8. ThaddeusJiang commented on Jun 8, 2018

    @ThaddeusJiang
    Contributor

    @gaearon

    when user drags a Element, 'focus' is not supported Exception be thrown

    Environment

    • IE11
    • React 16.4

    step 1

    step 2

    step 3

  9. gaearon commented on Jun 8, 2018

    @gaearon
    Collaborator

    OK. Somebody want to send a PR that reverts #11800?

  10. ThaddeusJiang commented on Jun 8, 2018

    @ThaddeusJiang
    Contributor

    Yes, I do.

  11. gaearon commented on Jun 11, 2018

    @gaearon
    Collaborator

    Fixed in #12996

  12. gaearon commented on Jun 13, 2018

    @gaearon
    Collaborator

    Fixed in React 16.4.1.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions