File tree 2 files changed +12
-3
lines changed
packages/react/src/SelectPanel
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @primer/react " : patch
3
+ ---
4
+
5
+ fix(SelectPanel): differentiate onCancel gesture from escape
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ interface SelectPanelBaseProps {
74
74
subtitle ?: string | React . ReactElement
75
75
onOpenChange : (
76
76
open : boolean ,
77
- gesture : 'anchor-click' | 'anchor-key-press' | 'click-outside' | 'escape' | 'selection' ,
77
+ gesture : 'anchor-click' | 'anchor-key-press' | 'click-outside' | 'escape' | 'selection' | 'cancel' ,
78
78
) => void
79
79
placeholder ?: string
80
80
// TODO: Make `inputLabel` required in next major version
@@ -333,6 +333,10 @@ export function SelectPanel({
333
333
[ onOpenChange ] ,
334
334
)
335
335
336
+ const onCancelRequested = useCallback ( ( ) => {
337
+ onOpenChange ( false , 'cancel' )
338
+ } , [ onOpenChange ] )
339
+
336
340
const renderMenuAnchor = useMemo ( ( ) => {
337
341
if ( renderAnchor === null ) {
338
342
return null
@@ -473,7 +477,7 @@ export function SelectPanel({
473
477
className = { classes . ResponsiveCloseButton }
474
478
onClick = { ( ) => {
475
479
onCancel ( )
476
- onClose ( 'escape' )
480
+ onCancelRequested ( )
477
481
} }
478
482
/>
479
483
) }
@@ -523,7 +527,7 @@ export function SelectPanel({
523
527
size = "medium"
524
528
onClick = { ( ) => {
525
529
onCancel ( )
526
- onClose ( 'escape' )
530
+ onCancelRequested ( )
527
531
} }
528
532
>
529
533
Cancel
You can’t perform that action at this time.
0 commit comments