Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't render collapsed Collapse's children #507

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 32 additions & 30 deletions components/collapse/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function getHeight(node) {
return node.scrollHeight;
}

/** Collapsable accordion component. Useful for nodes that have 'height: auto'. Ported from reactstrap */
/** Collapsible accordion component. Useful for nodes that have 'height: auto'. Ported from reactstrap */
export const Collapse = forwardClassRef(
class Collapse extends Component {
static propTypes = propTypes;
Expand Down Expand Up @@ -102,35 +102,37 @@ export const Collapse = forwardClassRef(
{status => {
const style = height === null ? null : { height };
return (
<Box
{...otherProps}
transitionStatus={status}
style={{ ...otherProps.style, ...style }}
ref={forwardedRef}
display={status === TransitionStatuses.EXITED ? 'none' : undefined}
position={
status === TransitionStatuses.ENTERING || status === TransitionStatuses.EXITING
? 'relative'
: ''
}
height={
status === TransitionStatuses.ENTERING || status === TransitionStatuses.EXITING
? '0'
: ''
}
transition={
status === TransitionStatuses.ENTERING || status === TransitionStatuses.EXITING
? 'height 0.2s ease-in'
: ''
}
css={`
${status === TransitionStatuses.ENTERING || status === TransitionStatuses.EXITING
? 'overflow: hidden'
: ''}
`}
>
{children}
</Box>
status !== TransitionStatuses.EXITED && (
<Box
{...otherProps}
transitionStatus={status}
style={{ ...otherProps.style, ...style }}
ref={forwardedRef}
position={
status === TransitionStatuses.ENTERING || status === TransitionStatuses.EXITING
? 'relative'
: ''
}
height={
status === TransitionStatuses.ENTERING || status === TransitionStatuses.EXITING
? '0'
: ''
}
transition={
status === TransitionStatuses.ENTERING || status === TransitionStatuses.EXITING
? 'height 0.2s ease-in'
: ''
}
css={`
${status === TransitionStatuses.ENTERING ||
status === TransitionStatuses.EXITING
? 'overflow: hidden'
: ''}
`}
>
{children}
</Box>
)
);
}}
</Transition>
Expand Down