tailwindlabs / tailwindui-issues

A place to report bugs discovered in Tailwind UI.
236 stars 4 forks source link

Popover.Panel component bug #1359

Closed JoHeyJo closed 1 year ago

JoHeyJo commented 1 year ago

What component (if applicable)

Describe the bug If I check one of the checkboxes in the dropdown panel, close it, and open it again, the checkbox is "unchecked". The checkbox seems to get reset every time the panel is closed. Instead of the normal behavior which would be for the checkbox to remain "checked".

To Reproduce

  1. Copy " Category Filters-With centered text and dropdown product filters" template to IDE.( I am using VSCode)
  2. I am rendering that template with React
  3. Open any of the dropdown panels and check any of the boxes, close it...
  4. Reopen and the box is unchecked

Expected behavior When the user opens the dropdown panel and "checks" any checkbox and closes the dropdown panel. The checkbox should remain "checked" until user "unchecks" it.

Screenshots If applicable, add screenshots to help explain your problem.

Browser/Device (if applicable)

Additional context Input tag and label tag are pointing to each other. Also, I've tried the code exactly as it comes from Tailwind, without any modifications and the issue persists. However, it seems to be working just fine on the website. Link above.

RobinMalfait commented 1 year ago

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

This is expected behaviour because the checkboxes aren't hooked up to anything. We didn't want to do that because we didn't want it to be too opinionated. For example we can:

Right now what is happening is that the panel is unmounting / remounting and therefore throwing away DOM related state.

What you can do depends on what you actually want:

I hope this helps!

JoHeyJo commented 1 year ago

Robin,

thank you, that is very helpful and informative about the inner workings Panel.Popover. I wasn't aware of a unmount property which is nice to know about. Thanks for pointing all of those options out. I did some digging bc I thought the checkbox was tied to the state so I started thinking that maybe it worked independently of it or something else I wasn't aware of. Anyway, I found that it wasn't tied to the component state but rather to how the data was being passed to the component itself, which did reflect the info in the dev tools. I don't think I would have thought to go back and double-check that anytime soon since I thought it was all already tied together. 😅 Thanks again!

On Fri, Nov 4, 2022 at 12:16 PM Robin Malfait @.***> wrote:

Closed #1359 https://github.com/tailwindlabs/tailwindui-issues/issues/1359 as completed.

— Reply to this email directly, view it on GitHub https://github.com/tailwindlabs/tailwindui-issues/issues/1359#event-7743350752, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVKIQIR2GLHD2QCXQPCVO73WGVOKRANCNFSM6AAAAAARXO7EAY . You are receiving this because you authored the thread.Message ID: @.*** com>

-- Joannes Figueroa