Skip to content

Commit b90ec19

Browse files
committed
feat(design-system): add onCloseAutoFocus
1 parent 6233e27 commit b90ec19

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

.changeset/few-fishes-sip.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@strapi/design-system': minor
3+
---
4+
5+
feat: add onCloseAutoFocus to Select

packages/strapi-design-system/src/Select/MultiSelect.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { Tag } from '../Tag';
1717
import { Typography } from '../Typography';
1818

1919
type MultiSelectPropsWithoutLabel = Omit<SelectParts.MultiSelectProps, 'value' | 'multi'> &
20+
Pick<SelectParts.ContentProps, 'onCloseAutoFocus'> &
2021
Pick<SelectParts.TriggerProps, 'clearLabel' | 'onClear' | 'size' | 'startIcon' | 'placeholder'> &
2122
Pick<FieldProps, 'hint' | 'id' | 'error'> & {
2223
/**
@@ -55,6 +56,7 @@ export const MultiSelect = React.forwardRef<HTMLDivElement, MultiSelectProps>(
5556
labelAction,
5657
onChange,
5758
onClear,
59+
onCloseAutoFocus,
5860
onReachEnd,
5961
placeholder,
6062
required,
@@ -197,7 +199,7 @@ export const MultiSelect = React.forwardRef<HTMLDivElement, MultiSelectProps>(
197199
</SelectParts.Value>
198200
</SelectParts.Trigger>
199201
<SelectParts.Portal>
200-
<SelectParts.Content position="popper" sideOffset={4}>
202+
<SelectParts.Content position="popper" sideOffset={4} onCloseAutoFocus={onCloseAutoFocus}>
201203
<SelectParts.Viewport ref={viewportRef}>
202204
{children}
203205
<Box id={intersectionId} width="100%" height="1px" />

packages/strapi-design-system/src/Select/SingleSelect.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useIntersection } from '../hooks/useIntersection';
1111
import { Typography } from '../Typography';
1212

1313
type SingleSelectPropsWithoutLabel = Omit<SelectParts.SingleSelectProps, 'value'> &
14+
Pick<SelectParts.ContentProps, 'onCloseAutoFocus'> &
1415
Pick<SelectParts.TriggerProps, 'clearLabel' | 'onClear' | 'size' | 'startIcon' | 'placeholder'> &
1516
Pick<FieldProps, 'error' | 'hint' | 'id'> & {
1617
/**
@@ -41,7 +42,6 @@ export const SingleSelect = React.forwardRef<SingleSelectInputElement, SingleSel
4142
forwardedRef,
4243
) => {
4344
const generatedId = useId(id);
44-
4545
/**
4646
* Because the trigger needs to be a `div` to allow the clear
4747
* button & tags to be clickable, we need to manually focus it.
@@ -98,6 +98,7 @@ export const SingleSelectInput = React.forwardRef<SingleSelectInputElement, Sing
9898
label,
9999
onChange,
100100
onClear,
101+
onCloseAutoFocus,
101102
onReachEnd,
102103
placeholder,
103104
required,
@@ -194,7 +195,7 @@ export const SingleSelectInput = React.forwardRef<SingleSelectInputElement, Sing
194195
</SelectParts.Value>
195196
</SelectParts.Trigger>
196197
<SelectParts.Portal>
197-
<SelectParts.Content position="popper" sideOffset={4}>
198+
<SelectParts.Content position="popper" sideOffset={4} onCloseAutoFocus={onCloseAutoFocus}>
198199
<SelectParts.Viewport ref={viewportRef}>
199200
{children}
200201
<Box id={intersectionId} width="100%" height="1px" />

0 commit comments

Comments
 (0)