headlessui: Closing Dialog breaks site on Safari mobile (

Closing a dialog in Safari on iOS 13.2 renders my app unusable. The problem seems to be the node <div id="headlessui-portal-root">…</div> which stays in the DOM even after closing the dialog. In other browsers, this node is removed from the DOM.

What package within Headless UI are you using?

@headlessui/react”: “1.6.6”,

What browser are you using?

Safari ios 13

Reproduction URL

  1. clone repo https://github.com/tianyingchun/headlessui
  2. yarn install
  3. open http://localhost:3000/ on the modern mobile safari (ios15) it works fine .
  4. open http://localhost:3000/ on the safari of ios 13 click Open Sidebar it will popup modal, while close dialog please see below dom image

while sidebar modal is open, and try to close it , and then try to re-click Open Sidebar, the web page is no response. the reasons as below picture shown.

image

Describe your issue while Dialog closed(transition end) it should clean <div id="#headlessui-portal-root" />, && remove <html style="overflow: hidden;" /> at safari of (ios <14 )

related existed issue https://github.com/tailwindlabs/headlessui/issues/1538

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 6
  • Comments: 16

Most upvoted comments

Also experiencing this on latest Chrome. As mentioned, the Dialog component does not seem to clean up after itself when combined with Transition (as the TailwindUI code does).

I was able to work around this by setting the Dialog open prop as well as the Transition that wraps it.

E.g., from this:

    <Transition.Root show={isOpen} as={Fragment}>
      <Dialog as="div" className="relative z-10" onClose={onClose}>

To this:

    <Transition.Root show={isOpen} as={Fragment}>
      <Dialog as="div" className="relative z-10" open={isOpen} onClose={onClose}>