-
Notifications
You must be signed in to change notification settings - Fork 67
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
[Focus lock breakage after updating React to V17]: Unable to get focus inside dialog content( react portal) which is being created from focus-lock content #134
Comments
Oh, welcome to the shiny new world. The proper, cross-version compatible fix might take a while, but this is something that had to be made in order to support many existing UI patterns and verify the results. Gonna start with reading some docs and PR you've linked. So bear with me and feel free to participate. Meanwhile, you can use |
Hello, and first of all thanks for creating such an awesome library! I wanted to check on the status of this issue as there have been no comments since January. Any idea on possible schedule? A large amount of work for a workaround hangs in the balance, so any kind of estimate (or lack thereof), would help me decide if the workaround is worth it. Thank you in advance. |
Unfortunately, I still don't get a moment to work on this, but I am looking forward to work on this part of ecosystem soon as "we" are on React 17 as well and soon will hit the same issue. |
Thank you for the reply. I think we'll have to build a workaround for now then :) |
I looked into this a little bit based on the research from @ramareddy12345. The changes made in https://github.com/johnathanludwig/react-focus-lock/commit/63f84fa244b0379bd2b551b4a920ddb43201c76c fix the issue for our use case and tests continue to pass. However, I do see test failures when I upgrade this library to use react 17. These test failures seem to occur regardless of the change made and are related to autofocus. In our case with react 17, autofocus still seemed to be working properly. I'm not really sure of the test issues or how to fix them. If you are willing to accept it I can open a PR for the referenced change which should still pass tests until this library uses react 17 for testing. Here is an output of the failures:
|
@theKashey Any thoughts on @johnathanludwig 's fix linked above? Is the capture absolutely necessary? And if so, why? |
So a few things:
|
Hello,
We are using focus-lock library in our application. We recently updated react to V17 from V16+.
We have observed that because of change in react-dom event flow (facebook/react#18195) now focus lock events order is getting changed resulting in focus issue.
Earlier: Focus order as follows
focus event (lock.js)
focus-in event(trap.js)
blur event (trap.js)
Now: Focus order as follows
focus-in event(trap.js)
focus event (lock.js)
blur event (trap.js)
And also we have observed that, with react-dom V17 if we change focus-in event handler(trap.js) from capture to bubbling phase then event order triggered same like earlier and issue got fixed.
I replicated the scenario in codesandbox and attaching the same.
Steps to reproduce:
Working - With React V16
https://codesandbox.io/s/react-focus-lock-forked-z5pk2
Not working - With React V17
https://codesandbox.io/s/react-focus-lock-forked-t8pzl
Due to this issue user has to click twice on the input controls which are part of dialog to get focus.
Could you please help us on this usecase.
The text was updated successfully, but these errors were encountered: