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

Feat/skeleton to drawer #82

Merged
merged 16 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

- Skeleton when opening drawer

## [0.18.0] - 2024-11-01

### Added
Expand Down
17 changes: 14 additions & 3 deletions react/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ function Drawer(props: Props) {
const hasHeaderBlock = Boolean(useChildBlock({ id: 'drawer-header' }))
const { state: menuState, openMenu, closeMenu } = useMenuState()
const { isOpen: isMenuOpen, hasBeenOpened: hasMenuBeenOpened } = menuState
const [shouldRenderChildren, setShouldRenderChildren] = useState(
renderingStrategy === 'eager'
)
const [isMoving, setIsMoving] = useState(false)

// Always add the listener for 'openDrawer' events, since they're sent by
Expand Down Expand Up @@ -187,8 +190,16 @@ function Drawer(props: Props) {

const overlayVisible = backdropMode === 'visible' && isMenuOpen

const shouldRenderChildren =
renderingStrategy === 'eager' || hasMenuBeenOpened
useEffect(() => {
if (isMenuOpen || hasMenuBeenOpened || renderingStrategy === 'eager') {
setShouldRenderChildren(true)
}
}, [
hasMenuBeenOpened,
renderingStrategy,
setShouldRenderChildren,
isMenuOpen,
])

return (
<DrawerContextProvider value={contextValue}>
Expand Down Expand Up @@ -254,7 +265,7 @@ function Drawer(props: Props) {
className={`${handles.childrenContainer} flex flex-grow-1`}
onClick={handleContainerClick}
>
{shouldRenderChildren && children}
{shouldRenderChildren ? children : <></>}
</div>
{/* eslint-enable jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
</div>
Expand Down
Loading