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

Reopen #22481 Fixed modal closing issue #22484

Merged
merged 4 commits into from Oct 2, 2021
Merged

Conversation

@Biki-das
Copy link
Contributor

@Biki-das Biki-das commented Oct 1, 2021

@bvaughn hope this is fine

@@ -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);
Copy link
Contributor

@bvaughn bvaughn Oct 1, 2021

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;
``;
Copy link
Contributor

@bvaughn bvaughn Oct 1, 2021

What's this? Can you delete this newly added line?

Copy link
Contributor Author

@Biki-das Biki-das Oct 1, 2021

Yeah sure

@Biki-das
Copy link
Contributor Author

@Biki-das Biki-das commented Oct 1, 2021

@bvaughn sorry to disturb you , but i actually learned today , thanks for your patience and feedback

@bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Oct 1, 2021

The code looks right now 👍🏼 but please run yarn prettier to fix the styling/lint CI failure. :)

@Biki-das
Copy link
Contributor Author

@Biki-das Biki-das commented Oct 1, 2021

The code looks right now 👍🏼 but please run yarn prettier to fix the styling/lint CI failure. :)

Okay!

@Biki-das
Copy link
Contributor Author

@Biki-das Biki-das commented Oct 1, 2021

The code looks right now 👍🏼 but please run yarn prettier to fix the styling/lint CI failure. :)

Can i run that without pulling a PR request or i need to do a fresh commit again @bvaughn

@bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Oct 1, 2021

Just run it locally, then commit and push an update :)

yarn prettier
git add .
git commit -m "Formatting"
git push Biki-das localmain

@Biki-das
Copy link
Contributor Author

@Biki-das Biki-das commented Oct 1, 2021

The code looks right now 👍🏼 but please run yarn prettier to fix the styling/lint CI failure. :)

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!

@bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Oct 1, 2021

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),

@bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Oct 1, 2021

I just made the commit for you. Give it a sec to see if it works

@Biki-das
Copy link
Contributor Author

@Biki-das Biki-das commented Oct 1, 2021

I just made the commit for you. Give it a sec to see if it works

Yeah works!

@bvaughn bvaughn merged commit a4bc8ae into facebook:main Oct 2, 2021
33 checks passed
@bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Oct 2, 2021

There we go.

@Biki-das
Copy link
Contributor Author

@Biki-das Biki-das commented Oct 2, 2021

Would you like to review 2 more PR of mine?

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

Successfully merging this pull request may close these issues.

None yet

3 participants