Reopen #22481 Fixed modal closing issue #22484
Conversation
| @@ -239,7 +239,8 @@ export function useModalDismissSignal( | |||
| ownerDocument = ((modalRef.current: any): HTMLDivElement).ownerDocument; | |||
| ownerDocument.addEventListener('keydown', handleDocumentKeyDown); | |||
| if (dismissOnClickOutside) { | |||
| ownerDocument.addEventListener('click', handleDocumentClick); | |||
| ownerDocument.addEventListener('click', handleDocumentClick, true); | |||
| ownerDocument.removeEventListener('click', handleDocumentClick, true); | |||
This isn't quite right. You're adding (and then immediately removing) the listener.
Here's what you what:
// It's important to listen to the ownerDocument to support the browser extension.
// Here we use portals to render individual tabs (e.g. Profiler),
// and the root document might belong to a different window.
ownerDocument = ((modalRef.current: any): HTMLDivElement).ownerDocument;
ownerDocument.addEventListener('keydown', handleDocumentKeyDown);
if (dismissOnClickOutside) {
ownerDocument.addEventListener('click', handleDocumentClick, true);
}
}, 0);
return () => {
if (timeoutID !== null) {
clearTimeout(timeoutID);
}
if (ownerDocument !== null) {
ownerDocument.removeEventListener('keydown', handleDocumentKeyDown);
ownerDocument.removeEventListener('click', handleDocumentClick, true);
}
};| @@ -232,6 +232,7 @@ export function useModalDismissSignal( | |||
| // In that case, we don't want to listen to the pre-existing event. | |||
| let timeoutID = setTimeout(() => { | |||
| timeoutID = null; | |||
| ``; | |||
What's this? Can you delete this newly added line?
Yeah sure
|
@bvaughn sorry to disturb you , but i actually learned today , thanks for your patience and feedback |
|
The code looks right now 👍🏼 but please run |
Okay! |
Can i run that without pulling a PR request or i need to do a fresh commit again @bvaughn |
|
Just run it locally, then commit and push an update :) yarn prettier
git add .
git commit -m "Formatting"
git push Biki-das localmain |
Can i run that without pulling a PR request or i need to do a fresh commit again @bvaughn thanks a lot! You made my day! |
|
Wherever you checked out your fork of this repo to create your PR initially (I don't know where) I just pulled your branch down locally and ran prettier. Looks like all you need to change is this: diff --git a/packages/react-devtools-shared/src/devtools/views/hooks.js b/packages/react-devtools-shared/src/devtools/views/hooks.js
index 4aa157f58..76dad5677 100644
--- a/packages/react-devtools-shared/src/devtools/views/hooks.js
+++ b/packages/react-devtools-shared/src/devtools/views/hooks.js
@@ -232,7 +232,6 @@ export function useModalDismissSignal(
// In that case, we don't want to listen to the pre-existing event.
let timeoutID = setTimeout(() => {
timeoutID = null;
-
// It's important to listen to the ownerDocument to support the browser extension.
// Here we use portals to render individual tabs (e.g. Profiler),
|
|
I just made the commit for you. Give it a sec to see if it works |
Yeah works! |
|
There we go. |
|
Would you like to review 2 more PR of mine? |
@bvaughn hope this is fine
The text was updated successfully, but these errors were encountered: