@uniai-fe/uds-templates 0.4.17 → 0.4.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useCallback, useEffect, useMemo } from "react";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
4
4
|
import type { CSSProperties } from "react";
|
|
5
5
|
|
|
6
6
|
import clsx from "clsx";
|
|
@@ -31,6 +31,7 @@ export function ModalRoot({
|
|
|
31
31
|
className,
|
|
32
32
|
}: ModalRootProps) {
|
|
33
33
|
const { updateModal, closeModal } = useModal();
|
|
34
|
+
const surfaceRef = useRef<HTMLDivElement | null>(null);
|
|
34
35
|
|
|
35
36
|
useEffect(() => {
|
|
36
37
|
if (modalProps.show === "init") {
|
|
@@ -38,6 +39,15 @@ export function ModalRoot({
|
|
|
38
39
|
}
|
|
39
40
|
}, [modalProps.show, stackKey, updateModal]);
|
|
40
41
|
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (modalProps.show !== true) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// modal open 시 background form focus를 surface로 우회해 Enter 재전파를 막는다.
|
|
48
|
+
surfaceRef.current?.focus({ preventScroll: true });
|
|
49
|
+
}, [modalProps.show]);
|
|
50
|
+
|
|
41
51
|
const handleClose = useCallback(() => {
|
|
42
52
|
if (modalProps.closeOnOutsideClick === false) {
|
|
43
53
|
return;
|
|
@@ -94,6 +104,8 @@ export function ModalRoot({
|
|
|
94
104
|
aria-modal="true"
|
|
95
105
|
onClick={stopPropagation}
|
|
96
106
|
style={surfaceStyle}
|
|
107
|
+
tabIndex={-1}
|
|
108
|
+
ref={surfaceRef}
|
|
97
109
|
>
|
|
98
110
|
<ModalContainer stackKey={stackKey} {...modalProps} />
|
|
99
111
|
</div>
|