File tree Expand file tree Collapse file tree
packages/react/src/SelectPanel Expand file tree Collapse file tree 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 {
7474 subtitle ?: string | React . ReactElement
7575 onOpenChange : (
7676 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' ,
7878 ) => void
7979 placeholder ?: string
8080 // TODO: Make `inputLabel` required in next major version
@@ -333,6 +333,10 @@ export function SelectPanel({
333333 [ onOpenChange ] ,
334334 )
335335
336+ const onCancelRequested = useCallback ( ( ) => {
337+ onOpenChange ( false , 'cancel' )
338+ } , [ onOpenChange ] )
339+
336340 const renderMenuAnchor = useMemo ( ( ) => {
337341 if ( renderAnchor === null ) {
338342 return null
@@ -473,7 +477,7 @@ export function SelectPanel({
473477 className = { classes . ResponsiveCloseButton }
474478 onClick = { ( ) => {
475479 onCancel ( )
476- onClose ( 'escape' )
480+ onCancelRequested ( )
477481 } }
478482 />
479483 ) }
@@ -523,7 +527,7 @@ export function SelectPanel({
523527 size = "medium"
524528 onClick = { ( ) => {
525529 onCancel ( )
526- onClose ( 'escape' )
530+ onCancelRequested ( )
527531 } }
528532 >
529533 Cancel
You can’t perform that action at this time.
0 commit comments