Skip to content

Commit 21676c1

Browse files
authored
fix: wrapping content of dialog in overlay to restore pointer-events (#1930)
1 parent 7dc441e commit 21676c1

File tree

3 files changed

+47
-14
lines changed

3 files changed

+47
-14
lines changed

.changeset/tricky-plants-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': patch
3+
---
4+
5+
fix: wrapping content of dialog in overlay to restore pointer-events

docs/stories/04-components/Dialog.stories.tsx

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Meta, StoryObj } from '@storybook/react';
22
import { fn } from '@storybook/test';
3-
import { Button, Dialog, Flex, Radio } from '@strapi/design-system';
3+
import { Button, Dialog, Field, Flex, Radio, SingleSelect, SingleSelectOption } from '@strapi/design-system';
44
import { WarningCircle } from '@strapi/icons';
55
import { outdent } from 'outdent';
66

@@ -33,20 +33,33 @@ const meta: Meta<DialogArgs> = {
3333
code: outdent`
3434
<Dialog.Root>
3535
<Dialog.Trigger>
36-
<Button variant="danger">Delete</Button>
36+
<Button variant="danger">Choose a fruit</Button>
3737
</Dialog.Trigger>
3838
<Dialog.Content>
3939
<Dialog.Header>Confirmation</Dialog.Header>
40-
<Dialog.Body icon={<WarningCircle fill="danger600" />}>Are you sure you want to delete this?</Dialog.Body>
40+
<Dialog.Body>
41+
<Field.Root width="100%">
42+
<Field.Label>What is your favourite fruit?</Field.Label>
43+
<SingleSelect placeholder="Pick a fruit...">
44+
<SingleSelectOption value="apple">Apple</SingleSelectOption>
45+
<SingleSelectOption value="avocado">Avocado</SingleSelectOption>
46+
<SingleSelectOption value="banana">Banana</SingleSelectOption>
47+
<SingleSelectOption value="kiwi">Kiwi</SingleSelectOption>
48+
<SingleSelectOption value="mango">Mango</SingleSelectOption>
49+
<SingleSelectOption value="orange">Orange</SingleSelectOption>
50+
<SingleSelectOption value="strawberry">Strawberry</SingleSelectOption>
51+
</SingleSelect>
52+
</Field.Root>
53+
</Dialog.Body>
4154
<Dialog.Footer>
4255
<Dialog.Cancel>
4356
<Button fullWidth variant="tertiary">
4457
Cancel
4558
</Button>
4659
</Dialog.Cancel>
4760
<Dialog.Action>
48-
<Button fullWidth variant="danger-light">
49-
Yes, delete
61+
<Button fullWidth variant="success-light">
62+
Confirm
5063
</Button>
5164
</Dialog.Action>
5265
</Dialog.Footer>
@@ -60,24 +73,37 @@ const meta: Meta<DialogArgs> = {
6073
return (
6174
<Dialog.Root {...args}>
6275
<Dialog.Trigger>
63-
<Button variant="danger">Delete</Button>
76+
<Button variant="default">Fruit manager</Button>
6477
</Dialog.Trigger>
6578
<Dialog.Content
6679
onOpenAutoFocus={onOpenAutoFocus}
6780
onCloseAutoFocus={onCloseAutoFocus}
6881
onEscapeKeyDown={onEscapeKeyDown}
6982
>
7083
<Dialog.Header>Confirmation</Dialog.Header>
71-
<Dialog.Body icon={icon}>Are you sure you want to delete this?</Dialog.Body>
84+
<Dialog.Body>
85+
<Field.Root width="100%">
86+
<Field.Label>What is your favourite fruit?</Field.Label>
87+
<SingleSelect placeholder="Pick a fruit...">
88+
<SingleSelectOption value="apple">Apple</SingleSelectOption>
89+
<SingleSelectOption value="avocado">Avocado</SingleSelectOption>
90+
<SingleSelectOption value="banana">Banana</SingleSelectOption>
91+
<SingleSelectOption value="kiwi">Kiwi</SingleSelectOption>
92+
<SingleSelectOption value="mango">Mango</SingleSelectOption>
93+
<SingleSelectOption value="orange">Orange</SingleSelectOption>
94+
<SingleSelectOption value="strawberry">Strawberry</SingleSelectOption>
95+
</SingleSelect>
96+
</Field.Root>
97+
</Dialog.Body>
7298
<Dialog.Footer>
7399
<Dialog.Cancel>
74100
<Button fullWidth variant="tertiary">
75101
Cancel
76102
</Button>
77103
</Dialog.Cancel>
78104
<Dialog.Action>
79-
<Button fullWidth variant="danger-light">
80-
Yes, delete
105+
<Button fullWidth variant="success-light">
106+
Confirm
81107
</Button>
82108
</Dialog.Action>
83109
</Dialog.Footer>
@@ -108,7 +134,7 @@ export const Children = {
108134
return (
109135
<Dialog.Root {...args}>
110136
<Dialog.Trigger>
111-
<Button variant="danger">Delete</Button>
137+
<Button variant="default">Fruit manager</Button>
112138
</Dialog.Trigger>
113139
<Dialog.Content
114140
onOpenAutoFocus={onOpenAutoFocus}

packages/design-system/src/components/Dialog/Dialog.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as React from 'react';
33
import * as AlertDialog from '@radix-ui/react-alert-dialog';
44
import { styled } from 'styled-components';
55

6+
import { setOpacity } from '../../helpers/setOpacity';
67
import { Flex, FlexComponent, FlexProps } from '../../primitives/Flex';
78
import { Typography, TypographyComponent, TypographyProps } from '../../primitives/Typography';
89
import { ANIMATIONS } from '../../styles/motion';
@@ -38,18 +39,19 @@ interface ContentProps extends AlertDialog.AlertDialogContentProps {}
3839
const Content = React.forwardRef<ContentElement, ContentProps>((props, forwardedRef) => {
3940
return (
4041
<AlertDialog.Portal>
41-
<Overlay />
42-
<ContentImpl ref={forwardedRef} {...props} />
42+
<Overlay>
43+
<ContentImpl ref={forwardedRef} {...props} />
44+
</Overlay>
4345
</AlertDialog.Portal>
4446
);
4547
});
4648

4749
const Overlay = styled(AlertDialog.Overlay)`
48-
background-color: ${(props) => props.theme.colors.neutral800};
50+
background: ${(props) => setOpacity(props.theme.colors.neutral800, 0.2)};
4951
position: fixed;
5052
inset: 0;
5153
z-index: ${(props) => props.theme.zIndices.overlay};
52-
opacity: 0.2;
54+
will-change: opacity;
5355
5456
@media (prefers-reduced-motion: no-preference) {
5557
animation: ${ANIMATIONS.overlayFadeIn} ${(props) => props.theme.motion.timings['200']}

0 commit comments

Comments
 (0)