|
1 |
| -import { Button, HStack, Modal, Text } from '@hope-ui/core' |
2 |
| -import { children, createSignal, createEffect, Show, onMount } from 'solid-js' |
| 1 | +import { HStack, Modal } from '@hope-ui/core' |
| 2 | +import { children, createEffect } from 'solid-js' |
3 | 3 | import { openModalStatus } from '@src/store/ui/selectors'
|
4 | 4 | import { setOpenModal, type IModalMenu } from '@src/store/ui/ui'
|
5 | 5 | import './styles.css'
|
6 | 6 |
|
7 | 7 | const ModalMenu = (props: IModalMenu) => {
|
8 |
| - const [ref, setRef] = createSignal<HTMLElement>() |
9 | 8 | const Children = children(() => props.children)
|
10 |
| - const clickOutside = (e: MouseEvent) => { |
11 |
| - if (e.target instanceof HTMLElement) { |
12 |
| - if (ref() && (ref()?.contains(e.target) || ref()?.isSameNode(e.target))) return |
13 |
| - console.log('clicked outside') |
14 |
| - setOpenModal(false) |
15 |
| - } |
16 |
| - } |
17 | 9 | createEffect(() => {
|
18 |
| - if (openModalStatus()) { |
19 |
| - document.addEventListener('click', clickOutside) |
20 |
| - return |
21 |
| - } |
22 |
| - document.removeEventListener('click', clickOutside) |
| 10 | + console.log('openModalStatus:', openModalStatus()) |
23 | 11 | })
|
24 | 12 | return (
|
25 | 13 | <>
|
26 | 14 | <Modal
|
27 | 15 | isOpen={openModalStatus() ?? false}
|
28 | 16 | onClose={() => setOpenModal(false)}
|
29 |
| - initialFocusSelector="#initial-focus"> |
| 17 | + initialFocusSelector={props.initialFocus}> |
30 | 18 | <Modal.Overlay />
|
31 | 19 | <Modal.Content p={4}>
|
32 | 20 | <HStack justifyContent="space-between" mb={4}>
|
33 | 21 | <Modal.Heading fontWeight="semibold">Title</Modal.Heading>
|
34 | 22 | <Modal.CloseButton />
|
35 | 23 | </HStack>
|
36 |
| - <Text mb={4}>The content of the Modal.</Text> |
37 |
| - <HStack justifyContent="flex-end" spacing={4}> |
38 |
| - <Button id="initial-focus" _focus={{ color: 'red' }}> |
39 |
| - Action |
40 |
| - </Button> |
41 |
| - </HStack> |
| 24 | + {Children()} |
42 | 25 | </Modal.Content>
|
43 | 26 | </Modal>
|
44 | 27 | </>
|
|
0 commit comments