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

Dialog.Panel outside click onClose execute twice . #1520

Closed
tianyingchun opened this issue May 29, 2022 · 2 comments
Closed

Dialog.Panel outside click onClose execute twice . #1520

tianyingchun opened this issue May 29, 2022 · 2 comments

Comments

@tianyingchun
Copy link

tianyingchun commented May 29, 2022

What package within Headless UI are you using?
"@headlessui/react": "^1.6.3",

What version of that package are you using?
"@headlessui/react": "^1.6.3",

What browser are you using?
Chrome

Reproduction URL

export const SidebarFilter: FC<SidebarFilterProps> = ({ show, onFilterOptionChanged, onFiltersClose }) => {
  const handleClose = useCallback((e) => {
    e.preventDefault;
    console.log('close...');
    // onFiltersClose();
  }, []);

  return (
  <Transition show={show} as={Fragment}>
           {/* While Dialog wrappered within <Transition /> we shoud not specificed open property here (cause of transition animation.), click outsite of Dialog.panel, it will trigger `onClose` twice  */}
      <Dialog  as="div" className="fixed inset-0 z-40 flex sm:hidden" onClose={handleClose}>
        <Dialog.Panel className="">
          {/* Filters */}
          <div className="h-80 w-80 bg-white">ssfwer</div>
        </Dialog.Panel>
      </Dialog>
    </Transition>
  );
};

Describe your issue
while click outside of dialog.panel always trigger onClose twice.

image

@tianyingchun
Copy link
Author

BTW, if we continue use Dialog.Overlay and without Dialoag.Panel it works fine.

@RobinMalfait
Copy link
Collaborator

Hey! Thank you for your bug report!
Much appreciated! 🙏

I'm going to close this as a duplicate of #1490

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

No branches or pull requests

2 participants