Skip to content
Merged
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
13 changes: 9 additions & 4 deletions src/SelectPanel/SelectPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,19 @@ export function SelectPanel({
onClose('selection')
}, [finalItemsSelected, onSelectedChange, onClose, selected])

const onCancelClickHandler = React.useCallback(
const onCloseOverlay = React.useCallback(
(gesture?: 'anchor-click' | 'click-outside' | 'escape') => {
setFinalItemsSelected(selectedItems)
onClose(gesture ?? 'escape')
},
[onClose, selectedItems]
)

const onCloseClickHandler = React.useCallback(() => {
setFinalItemsSelected(selectedItems)
onClose('escape')
}, [onClose, selectedItems])

const inputRef = React.useRef<HTMLInputElement>(null)
const titleId = useSSRSafeId()
const focusTrapSettings = {
Expand Down Expand Up @@ -196,7 +201,7 @@ export function SelectPanel({
anchorRef={anchorRef}
open={open}
onOpen={onOpen}
onClose={onCancelClickHandler}
onClose={onCloseOverlay}
overlayProps={{...overlayProps, onKeyPress: overlayKeyPressHandler, role: 'dialog', 'aria-labelledby': titleId}}
focusTrapSettings={focusTrapSettings}
focusZoneSettings={focusZoneSettings}
Expand All @@ -214,7 +219,7 @@ export function SelectPanel({
<Heading as="h1" id={titleId} sx={{fontSize: 1}}>
{title}
</Heading>
<IconButton icon={XIcon} aria-label="Close" variant="invisible" onClick={onCancelClickHandler} />
<IconButton icon={XIcon} aria-label="Close" variant="invisible" onClick={onCloseClickHandler} />
</Box>
<FilteredActionList
filterValue={filterValue}
Expand All @@ -239,7 +244,7 @@ export function SelectPanel({
borderTopWidth={1}
borderTopStyle="solid"
>
<Button onClick={onCancelClickHandler}>Cancel</Button>
<Button onClick={onCloseClickHandler}>Cancel</Button>
<Button variant="primary" onClick={onSaveClickHandler}>
Save
</Button>
Expand Down