Skip to content

Commit 202ad18

Browse files
authored
Merge pull request #33757 from storybookjs/norbert/fix-modal-in-popover
UI: Fix `z-index` problem with `popover`s and `modal`s nesting
2 parents 5176cb7 + e8d62a2 commit 202ad18

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

code/core/src/components/components/Popover/Popover.stories.tsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,26 +148,25 @@ export const WithoutColor = meta.story({
148148
},
149149
});
150150

151-
const PopoverWithModal = () => {
152-
const [isOpen, setIsOpen] = useState(false);
153-
return (
154-
<div>
155-
<Button ariaLabel={false} onClick={() => setIsOpen(true)}>
156-
Open modal
157-
</Button>
158-
<Modal open={isOpen} onOpenChange={setIsOpen}>
159-
<div>Hello</div>
160-
</Modal>
161-
</div>
162-
);
163-
};
164-
165151
export const WithModal = meta.story({
166152
render: () => {
167-
const [isPopoverOpen, setIsPopoverOpen] = useState(true);
153+
const [isPopoverOpen] = useState(true);
154+
const [isModalOpen, setIsModalOpen] = useState(false);
168155
return (
169156
<>
170-
<PopoverProvider visible={isPopoverOpen} popover={<PopoverWithModal />}>
157+
<PopoverProvider
158+
visible={isPopoverOpen}
159+
popover={
160+
<div>
161+
<Button ariaLabel={false} onClick={() => setIsModalOpen(true)}>
162+
Open modal
163+
</Button>
164+
<Modal open={isModalOpen} onOpenChange={setIsModalOpen}>
165+
<div>Hello</div>
166+
</Modal>
167+
</div>
168+
}
169+
>
171170
<Button ariaLabel={false}>Open popover</Button>
172171
</PopoverProvider>
173172
<div style={{ width: 100, height: 100, backgroundColor: 'thistle' }}></div>

0 commit comments

Comments
 (0)