Skip to content
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
1 change: 1 addition & 0 deletions packages/ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Bug Fixes

- `Drawer`: Restore the slide-out animation when the popup closes ([#77800](https://github.com/WordPress/gutenberg/pull/77800)).
- `Drawer`: Forward the `render` prop on `Drawer.Content` to the scroll container instead of leaking it as a DOM attribute, matching `Dialog.Content` ([#77941](https://github.com/WordPress/gutenberg/pull/77941)).

### Enhancements

Expand Down
36 changes: 24 additions & 12 deletions packages/ui/src/drawer/content.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { mergeProps, useRender } from '@base-ui/react';
import { Drawer as _Drawer } from '@base-ui/react/drawer';
import clsx from 'clsx';
import { forwardRef } from '@wordpress/element';
Expand Down Expand Up @@ -28,25 +29,36 @@ import type { ContentProps } from './types';
* the popup (gated by the scroll edge on vertical drawers).
*/
const Content = forwardRef< HTMLDivElement, ContentProps >(
function DrawerContent( { className, children, onScroll, ...props }, ref ) {
function DrawerContent(
{ className, render, children, onScroll, ...props },
ref
) {
const { ref: scrollStateRef, onScroll: scrollStateOnScroll } =
useOverlayScrollStateAttributes< HTMLDivElement >( onScroll );
const mergedRef = useMergeRefs( [ ref, scrollStateRef ] );

return (
<div
ref={ mergedRef }
className={ clsx(
const element = useRender( {
defaultTagName: 'div',
render,
ref: mergedRef,
props: mergeProps< 'div' >( props, {
className: clsx(
styles.content,
focusStyles[ 'outset-ring--focus-visible' ],
className
) }
onScroll={ scrollStateOnScroll }
{ ...props }
>
<_Drawer.Content>{ children }</_Drawer.Content>
</div>
);
),
onScroll: scrollStateOnScroll,
// `_Drawer.Content` carries the `[data-drawer-content]`
// marker that Base UI's swipe-dismiss logic uses to skip
// mouse-drag swipes started inside the body, preserving
// text selection. It must sit *inside* the scroll
// container so the popup's edge padding gutter falls
// outside the marker and stays mouse-draggable.
children: <_Drawer.Content>{ children }</_Drawer.Content>,
} ),
} );

return element;
}
);

Expand Down
Loading