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 @@
### New Features

- Add `InputControl` component ([#76653](https://github.com/WordPress/gutenberg/pull/76653)).
- `Dialog`: Expose `initialFocus` and `finalFocus` props on `Dialog.Popup` for custom focus management ([#76860](https://github.com/WordPress/gutenberg/pull/76860)).

### Bug Fixes

Expand Down
11 changes: 10 additions & 1 deletion packages/ui/src/dialog/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ const ThemeProvider: typeof ThemeProviderType =
* Uses a portal to render outside the DOM hierarchy.
*/
const Popup = forwardRef< HTMLDivElement, PopupProps >( function DialogPopup(
{ className, size = 'medium', children, ...props },
{
className,
size = 'medium',
initialFocus,
finalFocus,
children,
...props
},
ref
) {
return (
Expand All @@ -32,6 +39,8 @@ const Popup = forwardRef< HTMLDivElement, PopupProps >( function DialogPopup(
className,
styles[ `is-${ size }` ]
) }
initialFocus={ initialFocus }
finalFocus={ finalFocus }
{ ...props }
>
<DialogValidationProvider>
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/dialog/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export interface TriggerProps extends ComponentProps< 'button' > {
children?: ReactNode;
}

export interface PopupProps extends ComponentProps< 'div' > {
export interface PopupProps
extends ComponentProps< 'div' >,
Pick< _Dialog.Popup.Props, 'initialFocus' | 'finalFocus' > {
/**
* The content to be rendered inside the component.
*/
Expand Down
Loading