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

priorFocusedElem.focus() throws in IE11 #12763

Closed
kristiandupont opened this issue May 8, 2018 · 12 comments
Closed

priorFocusedElem.focus() throws in IE11 #12763

kristiandupont opened this issue May 8, 2018 · 12 comments

Comments

@kristiandupont
Copy link

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:

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

@jquense
Copy link
Contributor

jquense commented May 8, 2018

Can you put together a reproduction demonstrating the issue?

@gaearon
Copy link
Collaborator

gaearon commented May 8, 2018

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

@ThaddeusJiang
Copy link
Contributor

ThaddeusJiang commented Jun 7, 2018

I hava a same problem.

React 16.4

@gaearon
Copy link
Collaborator

gaearon commented Jun 7, 2018

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

@gaearon
Copy link
Collaborator

gaearon commented Jun 7, 2018

Can somebody with IE11 figure out if:

  • SVGs don't have focus() in IE11
  • If their focus() call throws on hidden elements
  • Something else?

@kristiandupont
Copy link
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

@gaearon
Copy link
Collaborator

gaearon commented Jun 7, 2018

Thanks!

@ThaddeusJiang
Copy link
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

@gaearon
Copy link
Collaborator

gaearon commented Jun 8, 2018

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

@ThaddeusJiang
Copy link
Contributor

Yes, I do.

@gaearon
Copy link
Collaborator

gaearon commented Jun 11, 2018

Fixed in #12996

@gaearon gaearon closed this as completed Jun 11, 2018
gaearon pushed a commit that referenced this issue Jun 11, 2018
* revert #11800

because #12763

* use try/catch for SVG in IE11

* use focusNode(element) when element.focus isn't a function.

* revert #11800
@gaearon
Copy link
Collaborator

gaearon commented Jun 13, 2018

Fixed in React 16.4.1.

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

No branches or pull requests

4 participants