Skip to content

Commit b5414a4

Browse files
泊淞zyliang96
泊淞
authored andcommitted
feat: support ssr
1 parent eb475fb commit b5414a4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@alifd/overlay",
3-
"version": "0.3.6",
3+
"version": "0.3.7",
44
"description": "overlay base component",
55
"files": [
66
"demo/",
@@ -67,7 +67,7 @@
6767
"url": "https://github.com/alibaba-fusion/overlay.git"
6868
},
6969
"license": "MIT",
70-
"homepage": "https://unpkg.com/@alifd/[email protected].6/build/index.html",
70+
"homepage": "https://unpkg.com/@alifd/[email protected].7/build/index.html",
7171
"lint-staged": {
7272
"@(src|scripts|docs/*/demo)/**/*.@(js|jsx|ts|tsx|md)": [
7373
"prettier --write"

src/overlay.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ const Overlay = React.forwardRef<HTMLDivElement, OverlayProps>((props, ref) => {
374374
// - react17 中,如果弹窗 mousedown 阻止了 e.stopPropagation(), 那么 document 就不会监听到事件,因为事件冒泡到挂载节点 rootElement 就中断了。
375375
// - https://reactjs.org/blog/2020/08/10/react-v17-rc.html#changes-to-event-delegation
376376
useListener(
377-
document,
377+
typeof document !== 'undefined' ? document : null,
378378
'mousedown',
379379
clickEvent,
380380
false,
@@ -392,7 +392,7 @@ const Overlay = React.forwardRef<HTMLDivElement, OverlayProps>((props, ref) => {
392392
}
393393
};
394394
useListener(
395-
document,
395+
typeof document !== 'undefined' ? document : null,
396396
'keydown',
397397
keydownEvent,
398398
false,
@@ -406,7 +406,9 @@ const Overlay = React.forwardRef<HTMLDivElement, OverlayProps>((props, ref) => {
406406
updatePosition();
407407
};
408408
useListener(
409-
overflowRef.current?.map((t) => (t === document.documentElement ? document : t)),
409+
typeof document !== 'undefined'
410+
? overflowRef.current?.map((t) => (t === document.documentElement ? document : t))
411+
: null,
410412
'scroll',
411413
scrollEvent,
412414
false,

0 commit comments

Comments
 (0)