question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Transition applied on content instead of Disclosure panel

See original GitHub issue

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

v1.4.2

What browser are you using?

Chrome (Tested on Edge and Firefox)

Reproduction URL

https://codesandbox.io/s/headlessui-disclosure-transition-issue-6ogxj?file=/src/App.tsx

Describe your issue

When i use Transition component on Disclosure Panel, the transition is applied on content of panel instead of panel himself. I tried to use only documentation exemple, outside my project, but the exemple on documentation was already broken 🤔

(Note: I have volontarily increase the duration of transition to expect the beahavor) (Note 2: I tried to use unmount prop already, but seems to component was systematicaly unmounted regardless this prop)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:9

github_iconTop GitHub Comments

17reactions
hodbncommented, Aug 1, 2022

Another workaround is to use the Disclosure component but manage its state manually using static, and then transition the height (or max-height to workaround the transition to auto):

<Disclosure>
  {({ open }) => (
    <>
      <Disclosure.Button>button</Disclosure.Button>
      <Transition
        show={open}
        className='overflow-hidden'
        enter='transition transition-[max-height] duration-200 ease-in'
        enterFrom='transform max-h-0'
        enterTo='transform max-h-screen'
        leave='transition transition-[max-height] duration-400 ease-out'
        leaveFrom='transform max-h-screen'
        leaveTo='transform max-h-0'
      >
        <Disclosure.Panel static>content</Disclosure.Panel>
      </Transition>
    </>
  )}
</Disclosure>
9reactions
benderillocommented, Jan 19, 2022

@RobinMalfait What about the behaviour I described in my comment? the sandbox example you provided also shows it. When you expand the Disclosure, the panel appears instantly, or at least everything shifts down instantly and the contents emerge from 0 opacity gradually (based on transition time function and duration). This produces ugly jump of a page content below the disclosure which the Transition meant to avoid at the first place.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disclosure - Headless UI
To animate the opening/closing of the menu panel, use the provided Transition component. All you need to do is wrap the Disclosure.Panel in...
Read more >
Disclosure Widgets - Adrian Roselli
When the content is visible, the element with role button has aria-expanded set ... by making the disclosed panels for each scroll instead....
Read more >
Popovers - Presentation - Human Interface Guidelines - Design
A popover is a transient view that appears above other content onscreen when people click or tap a control or interactive area.
Read more >
Create top-down slide animation using `Transition` from ...
This is how I created a similar animation for a disclosure panel: <Transition enter="transition ease duration-500 transform" ...
Read more >
National Bioengineered Food Disclosure Standard
The final rule adopts the same definition of “food” as used in the ... may choose to make a BE disclosure rather than...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found