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.

Drawer should not render contents unless expanded

See original GitHub issue

Describe the issue. What is the expected and unexpected behavior? The contents of a Drawer are rendered regardless of whether the drawer is opened or closed. There should at least be an option for the drawer to not render the panel contents when collapsed. But TBH I’m not sure what use case you would ever need the contents present unless the drawer is expanded. The reason for not rendering the contents is because they could be expensive to render and / or be network chatty. This is unnecessary if the contents are not visible to the user.

A workaround is to conditionally render the panelContents if the drawer is expanded or not. However this has a side effect of losing the animation. The Drawer component should render the content immediately before opening and perform the open animation. On collapsed, the Drawer should animate closed and then unmount the contents.

Please provide the steps to reproduce. Feel free to link CodeSandbox or another tool.

See patternfly react documentation samples: https://patternfly-react.surge.sh/documentation/react/components/drawer

Is this a bug or enhancement? If this issue is a bug, is this issue blocking you or is there a work-around? I see this as a Bug because the workaround loses the animation.

What is your product and what release version are you targeting? OpenShift 4.6

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
redallencommented, Jul 8, 2020

@seanforyou23 Yes we’ll have different approaches, but this isn’t the first time we conditionally render in React components that are hidden behind visible or hidden CSS in Core. It’d be nice if Core could conditionally hide components without having to write a new example each time. Perhaps a templating system other than handlebars could help, but that’s a separate issue.

0reactions
seanforyou23commented, Jul 8, 2020

I get it, just doing my part to try and keep the implementations aligned where possible. Just because it’s something we’re doing currently doesn’t necessarily mean it’s the best strategy. If a consumer is using another framework, let’s say Angular, and they want to implement Drawer, keep in mind the current recommendation is to reference core to see what the markup strategy should be. If users do this, they’d be following down a similar road where they’ll be met with these same issues. If we adjusted core to reflect what we plan to do in React, other JS implementations could also reference the same core examples without re-creating this same issue regarding unnecessary renders which could be expensive. Just food for thought!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Drawer that does not destroy content when hidden · Issue #4567
renderAll option does not really solves my problem, I need drawer that is always present but can be hidden. AntD: https://ant.design/components/ ...
Read more >
How to fix list items inside drawer in react - Stack Overflow
When I click on another expandable item, it should expand that item, but close previously opened. (not working); When I click on item...
Read more >
Prevent Drawer collapse - Telerik UI for Blazor - Documentation
I would like to prevent the Drawer from collapsing when an item from the navigation is clicked and switch between the collapsed and...
Read more >
Drawer API - Material UI - MUI
Override or extend the styles applied to the component. See CSS API below for more details. The elevation of the drawer. If true...
Read more >
Building a Drawer component in React | Development Simplified
A clickable title that on click expands an attached content ... Active just let's us know if the user has toggled the drawer...
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