-
Notifications
You must be signed in to change notification settings - Fork 47.7k
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
Removing tabIndex from component's attributes does not remove tabIndex once set #2528
Comments
Just to clarify… you're explicitly setting it to 0 but React ends up setting it to -1 instead? cc @syranide |
#1510 is the fix (default value is not identical to no attribute). I'll try to review and re-test it wednesday, it fixes quite a lot of edge-cases so it would be good to have it merged... |
Sorry, with the example code above:
I wanted to remove the tabIndex attribute completely in this case, not set it to 0. Explicitly setting a value works fine but something is assuming that if I had a tabIndex attribute, and then I set no explicit value, it should be 0. |
@mczepiel I believe you mixed up the order, anyway... there are a handful of DOM attributes which do not exhibit default behavior when set to the default value, the attribute has to be removed to restore default behavior. |
Oh wait, my bad @mczepiel ... yeah there's a second bug here, that you were referring to. |
I am having a very similar issue with the
When I disable the Similarly, I tried this approach. It didn't work either:
Still -- the |
I have the same problem with |
This is frustrating. I have a that can have editable cells. Once a<td /> element has a tabIndex prop set to 0 so it can be focused, removing the tabIndex doesn't remove it from the DOM but sets it to -1. This does remove it from the tab order, but still allows focus with the mouse.Is there any way to remove the tabIndex attribute once it's been set? |
@formula349 |
Yes, thank you I will use that for now |
@syranide I'm running into the same tabIndex issue. What do you mean by " On 0.13.3 the corresponding DOM node for a component which once had the tabIndex prop set but later had it removed will have its tabindex attribute set to -1. Setting a unique key on the component doesn't seem to change anything. |
@loganfuller Something like |
@syranide Ah, I see, to force the creation of a new DOM element. That would work, but I integrate with a third-party library on mount that would be expensive to re-initialize any time the associated DOM component is changed. I can add an extra wrapper with a static key to handle the integration, but wouldn't it be more performant to manually |
@loganfuller You can try https://github.com/Olical/react-faux-dom with that third-party library, maybe it helps. |
That requires a bit more manual work, but that is the best workaround yes. |
Maybe this changed recently, but I just tried this and it worked perfectly fine. tabindex was either there and set to '0' or in the other case it was not there.
|
Which version of React are you using? Should be fixed in React v15 |
My understanding is this has been fixed. |
Once a tab index has been put in place "removing" by the method seen below only ever sets it to -1, which does what I'd expect in that the element isn't focused when tabbing, but it is still focusable by clicking directly on the element.
The text was updated successfully, but these errors were encountered: