Stanko / react-animate-height

Lightweight React component for animating height using CSS transitions. Slide up/down the element, and animate it to any specific height.
https://muffinman.io/react-animate-height
MIT License
756 stars 53 forks source link

Set "display: none" when height is 0 #16

Closed apers closed 7 years ago

apers commented 7 years ago

Would it be possible to set "display: none" when height is 0 so the content doesn't take tab focus when hidden?

Stanko commented 7 years ago

Hello @apers, Recently I stumbled upon the same problem, I'll release new version today or tomorrow. Cheers!

Stanko commented 7 years ago

@apers I just released version 0.9.10 Can you please test and close the issue if it works, thanks!

Commit: https://github.com/Stanko/react-animate-height/commit/e52a3b9098e37b4bf4ddd7ce46022643de41156f

apers commented 7 years ago

That was quick! Tested and working, thanks!

nizioleque commented 11 months ago

@Stanko I think this functionality is breaking something else - it is causing animating from 0 to another value (using ResizeObserver) to not work.

This is what's happening, if I understand correctly:

Could you please let us disable this feature or find another way to fix the tab focus issue without display: none?

Here's a workaround I came up with:

tuff commented 10 months ago

@Stanko I'd also like to request that the display: none behaviour be opened to configuration.

I would like elements within zero-height containers to be able to receive focus, so that the user can tab to them and have the container be automatically expanded. I can also see where and why a developer would not want hidden elements to be focusable - both options are useful.

Currently I am using a similar !important workaround as @nizioleque, which seems brittle.

Stanko commented 10 months ago

hey, it is a valid point. I'll try to add it today or during the weekend.

Stanko commented 10 months ago

I just published v3.2.3 with a new disableDisplayNone prop.

I added an additional check - when height is zero and there is no children elements, display: none won't be applied.

Hope this helps, cheers!