Skip to content

Commit a54c5d9

Browse files
authored
Merge pull request #78 from headwirecom/feature/49-dialog-on-array-delete
replace window.confim with spectrum dialog
2 parents f4b508a + 52f3a2c commit a54c5d9

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

packages/spectrum/src/complex/SpectrumTableArrayControl.tsx

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ import {
5353
} from '@react-spectrum/table';
5454
import {
5555
ActionButton,
56+
AlertDialog,
5657
Button,
58+
DialogTrigger,
5759
Flex,
5860
Header,
5961
Heading,
@@ -271,23 +273,26 @@ class SpectrumTableArrayControl extends React.Component<
271273
{[
272274
...rowCells,
273275
<Cell key={`delete-row-${index}`}>
274-
<TooltipTrigger delay={0}>
275-
<ActionButton
276-
aria-label={`Delete row at ${index}`}
277-
onPress={() => {
278-
if (
279-
window.confirm(
280-
'Are you sure you wish to delete this item?'
281-
)
282-
) {
283-
this.confirmDelete(childPath, index);
284-
}
285-
}}
276+
<DialogTrigger>
277+
<TooltipTrigger delay={0}>
278+
<ActionButton aria-label={`Delete row at ${index}`}>
279+
<Delete />
280+
</ActionButton>
281+
<Tooltip>Delete</Tooltip>
282+
</TooltipTrigger>
283+
<AlertDialog
284+
variant='confirmation'
285+
title='Delete'
286+
primaryActionLabel='Delete'
287+
cancelLabel='Cancel'
288+
autoFocusButton='primary'
289+
onPrimaryAction={() =>
290+
this.confirmDelete(childPath, index)
291+
}
286292
>
287-
<Delete />
288-
</ActionButton>
289-
<Tooltip>Delete</Tooltip>
290-
</TooltipTrigger>
293+
Are you sure you wish to delete this item?
294+
</AlertDialog>
295+
</DialogTrigger>
291296
</Cell>,
292297
]}
293298
</Row>

0 commit comments

Comments
 (0)