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

fix: onOpenChange getting called twice when user clicks outside of the drawer #291

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

phxgg
Copy link

@phxgg phxgg commented Mar 7, 2024

Fixes: #290

I tried to test as many possibilities as I could, and I couldn't find anything that breaks by deleting that line of code.

Copy link

vercel bot commented Mar 7, 2024

@phxgg is attempting to deploy a commit to the emil Team on Vercel.

A member of the Team first needs to authorize it.

@phxgg
Copy link
Author

phxgg commented Mar 17, 2024

You said on this comment #290 (comment) that it was fixed in #297

However, #298 reintroduces the issue. I guess this is by accident?

@Semkoo
Copy link

Semkoo commented May 6, 2024

I have the same issue, so I had to create a quick hack around it. Hopefully this will get resolved soon

...
const [isFirstTimeOpened, setIsFirstTimeOpened] = useState(true);
...
const handleOnOpenChanges = useCallback(
    (aVal: boolean) => {
      if (isFirstTimeOpened) {
        setIsFirstTimeOpened(false);
        return;
      }
     ....
     }, [...]
);
... 

return (
    <Drawer
      open={open}
      onOpenChange={handleOnOpenChanges}
      direction={isDesktop ? "right" : "bottom"}
    >
    ... 
     </Drawer>
  );
};
    

@artemis-prime
Copy link
Contributor

Good call! That callback doesn't belong there, since closeDrawer(), which is below it, calls it as well

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

Successfully merging this pull request may close these issues.

onOpenChange getting called twice when user clicks outside of the drawer
3 participants