@rc-component/dialog 1.8.2 → 1.8.4
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/es/Dialog/Content/Panel.js +5 -2
- package/es/Dialog/index.js +7 -23
- package/lib/Dialog/Content/Panel.js +5 -2
- package/lib/Dialog/index.js +7 -23
- package/package.json +3 -3
|
@@ -40,7 +40,7 @@ const Panel = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
40
40
|
} = React.useContext(RefContext);
|
|
41
41
|
const internalRef = useRef(null);
|
|
42
42
|
const mergedRef = useComposeRef(holderRef, panelRef, internalRef);
|
|
43
|
-
useLockFocus(visible && isFixedPos && focusTrap !== false, () => internalRef.current);
|
|
43
|
+
const [ignoreElement] = useLockFocus(visible && isFixedPos && focusTrap !== false, () => internalRef.current);
|
|
44
44
|
React.useImperativeHandle(ref, () => ({
|
|
45
45
|
focus: () => {
|
|
46
46
|
internalRef.current?.focus({
|
|
@@ -122,7 +122,10 @@ const Panel = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
122
122
|
className: clsx(prefixCls, className),
|
|
123
123
|
onMouseDown: onMouseDown,
|
|
124
124
|
onMouseUp: onMouseUp,
|
|
125
|
-
tabIndex: -1
|
|
125
|
+
tabIndex: -1,
|
|
126
|
+
onFocus: e => {
|
|
127
|
+
ignoreElement(e.target);
|
|
128
|
+
}
|
|
126
129
|
}, /*#__PURE__*/React.createElement(MemoChildren, {
|
|
127
130
|
shouldUpdate: visible || forceRender
|
|
128
131
|
}, modalRender ? modalRender(content) : content));
|
package/es/Dialog/index.js
CHANGED
|
@@ -101,36 +101,26 @@ const Dialog = props => {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// >>> Content
|
|
104
|
-
const
|
|
105
|
-
const contentTimeoutRef = useRef(null);
|
|
106
|
-
|
|
107
|
-
// We need record content click in case content popup out of dialog
|
|
108
|
-
const onContentMouseDown = () => {
|
|
109
|
-
clearTimeout(contentTimeoutRef.current);
|
|
110
|
-
contentClickRef.current = true;
|
|
111
|
-
};
|
|
112
|
-
const onContentMouseUp = () => {
|
|
113
|
-
contentTimeoutRef.current = setTimeout(() => {
|
|
114
|
-
contentClickRef.current = false;
|
|
115
|
-
});
|
|
116
|
-
};
|
|
104
|
+
const mouseDownOnMaskRef = useRef(false);
|
|
117
105
|
|
|
118
106
|
// >>> Wrapper
|
|
119
107
|
// Close only when element not on dialog
|
|
120
108
|
let onWrapperClick = null;
|
|
121
109
|
if (maskClosable) {
|
|
122
110
|
onWrapperClick = e => {
|
|
123
|
-
if (
|
|
124
|
-
contentClickRef.current = false;
|
|
125
|
-
} else if (wrapperRef.current === e.target) {
|
|
111
|
+
if (wrapperRef.current === e.target && mouseDownOnMaskRef.current) {
|
|
126
112
|
onInternalClose(e);
|
|
127
113
|
}
|
|
128
114
|
};
|
|
129
115
|
}
|
|
116
|
+
function onWrapperMouseDown(e) {
|
|
117
|
+
mouseDownOnMaskRef.current = e.target === wrapperRef.current;
|
|
118
|
+
}
|
|
130
119
|
|
|
131
120
|
// ========================= Effect =========================
|
|
132
121
|
useEffect(() => {
|
|
133
122
|
if (visible) {
|
|
123
|
+
mouseDownOnMaskRef.current = false;
|
|
134
124
|
setAnimatedVisible(true);
|
|
135
125
|
saveLastOutSideActiveElementRef();
|
|
136
126
|
|
|
@@ -143,11 +133,6 @@ const Dialog = props => {
|
|
|
143
133
|
doClose();
|
|
144
134
|
}
|
|
145
135
|
}, [visible]);
|
|
146
|
-
|
|
147
|
-
// Remove direct should also check the scroll bar update
|
|
148
|
-
useEffect(() => () => {
|
|
149
|
-
clearTimeout(contentTimeoutRef.current);
|
|
150
|
-
}, []);
|
|
151
136
|
const mergedStyle = {
|
|
152
137
|
zIndex,
|
|
153
138
|
...wrapStyle,
|
|
@@ -176,11 +161,10 @@ const Dialog = props => {
|
|
|
176
161
|
className: clsx(`${prefixCls}-wrap`, wrapClassName, modalClassNames?.wrapper),
|
|
177
162
|
ref: wrapperRef,
|
|
178
163
|
onClick: onWrapperClick,
|
|
164
|
+
onMouseDown: onWrapperMouseDown,
|
|
179
165
|
style: mergedStyle
|
|
180
166
|
}, wrapProps), /*#__PURE__*/React.createElement(Content, _extends({}, props, {
|
|
181
167
|
isFixedPos: isFixedPos,
|
|
182
|
-
onMouseDown: onContentMouseDown,
|
|
183
|
-
onMouseUp: onContentMouseUp,
|
|
184
168
|
ref: contentRef,
|
|
185
169
|
closable: closable,
|
|
186
170
|
ariaId: ariaId,
|
|
@@ -49,7 +49,7 @@ const Panel = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
49
49
|
} = _react.default.useContext(_context.RefContext);
|
|
50
50
|
const internalRef = (0, _react.useRef)(null);
|
|
51
51
|
const mergedRef = (0, _ref.useComposeRef)(holderRef, panelRef, internalRef);
|
|
52
|
-
(0, _focus.useLockFocus)(visible && isFixedPos && focusTrap !== false, () => internalRef.current);
|
|
52
|
+
const [ignoreElement] = (0, _focus.useLockFocus)(visible && isFixedPos && focusTrap !== false, () => internalRef.current);
|
|
53
53
|
_react.default.useImperativeHandle(ref, () => ({
|
|
54
54
|
focus: () => {
|
|
55
55
|
internalRef.current?.focus({
|
|
@@ -131,7 +131,10 @@ const Panel = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
131
131
|
className: (0, _clsx.clsx)(prefixCls, className),
|
|
132
132
|
onMouseDown: onMouseDown,
|
|
133
133
|
onMouseUp: onMouseUp,
|
|
134
|
-
tabIndex: -1
|
|
134
|
+
tabIndex: -1,
|
|
135
|
+
onFocus: e => {
|
|
136
|
+
ignoreElement(e.target);
|
|
137
|
+
}
|
|
135
138
|
}, /*#__PURE__*/_react.default.createElement(_MemoChildren.default, {
|
|
136
139
|
shouldUpdate: visible || forceRender
|
|
137
140
|
}, modalRender ? modalRender(content) : content));
|
package/lib/Dialog/index.js
CHANGED
|
@@ -110,36 +110,26 @@ const Dialog = props => {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
// >>> Content
|
|
113
|
-
const
|
|
114
|
-
const contentTimeoutRef = (0, _react.useRef)(null);
|
|
115
|
-
|
|
116
|
-
// We need record content click in case content popup out of dialog
|
|
117
|
-
const onContentMouseDown = () => {
|
|
118
|
-
clearTimeout(contentTimeoutRef.current);
|
|
119
|
-
contentClickRef.current = true;
|
|
120
|
-
};
|
|
121
|
-
const onContentMouseUp = () => {
|
|
122
|
-
contentTimeoutRef.current = setTimeout(() => {
|
|
123
|
-
contentClickRef.current = false;
|
|
124
|
-
});
|
|
125
|
-
};
|
|
113
|
+
const mouseDownOnMaskRef = (0, _react.useRef)(false);
|
|
126
114
|
|
|
127
115
|
// >>> Wrapper
|
|
128
116
|
// Close only when element not on dialog
|
|
129
117
|
let onWrapperClick = null;
|
|
130
118
|
if (maskClosable) {
|
|
131
119
|
onWrapperClick = e => {
|
|
132
|
-
if (
|
|
133
|
-
contentClickRef.current = false;
|
|
134
|
-
} else if (wrapperRef.current === e.target) {
|
|
120
|
+
if (wrapperRef.current === e.target && mouseDownOnMaskRef.current) {
|
|
135
121
|
onInternalClose(e);
|
|
136
122
|
}
|
|
137
123
|
};
|
|
138
124
|
}
|
|
125
|
+
function onWrapperMouseDown(e) {
|
|
126
|
+
mouseDownOnMaskRef.current = e.target === wrapperRef.current;
|
|
127
|
+
}
|
|
139
128
|
|
|
140
129
|
// ========================= Effect =========================
|
|
141
130
|
(0, _react.useEffect)(() => {
|
|
142
131
|
if (visible) {
|
|
132
|
+
mouseDownOnMaskRef.current = false;
|
|
143
133
|
setAnimatedVisible(true);
|
|
144
134
|
saveLastOutSideActiveElementRef();
|
|
145
135
|
|
|
@@ -152,11 +142,6 @@ const Dialog = props => {
|
|
|
152
142
|
doClose();
|
|
153
143
|
}
|
|
154
144
|
}, [visible]);
|
|
155
|
-
|
|
156
|
-
// Remove direct should also check the scroll bar update
|
|
157
|
-
(0, _react.useEffect)(() => () => {
|
|
158
|
-
clearTimeout(contentTimeoutRef.current);
|
|
159
|
-
}, []);
|
|
160
145
|
const mergedStyle = {
|
|
161
146
|
zIndex,
|
|
162
147
|
...wrapStyle,
|
|
@@ -185,11 +170,10 @@ const Dialog = props => {
|
|
|
185
170
|
className: (0, _clsx.clsx)(`${prefixCls}-wrap`, wrapClassName, modalClassNames?.wrapper),
|
|
186
171
|
ref: wrapperRef,
|
|
187
172
|
onClick: onWrapperClick,
|
|
173
|
+
onMouseDown: onWrapperMouseDown,
|
|
188
174
|
style: mergedStyle
|
|
189
175
|
}, wrapProps), /*#__PURE__*/React.createElement(_Content.default, _extends({}, props, {
|
|
190
176
|
isFixedPos: isFixedPos,
|
|
191
|
-
onMouseDown: onContentMouseDown,
|
|
192
|
-
onMouseUp: onContentMouseUp,
|
|
193
177
|
ref: contentRef,
|
|
194
178
|
closable: closable,
|
|
195
179
|
ariaId: ariaId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rc-component/dialog",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.4",
|
|
4
4
|
"description": "dialog ui component for react",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@rc-component/motion": "^1.1.3",
|
|
53
53
|
"@rc-component/portal": "^2.1.0",
|
|
54
|
-
"@rc-component/util": "^1.
|
|
54
|
+
"@rc-component/util": "^1.9.0",
|
|
55
55
|
"clsx": "^2.1.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
@@ -87,4 +87,4 @@
|
|
|
87
87
|
"react": ">=18.0.0",
|
|
88
88
|
"react-dom": ">=18.0.0"
|
|
89
89
|
}
|
|
90
|
-
}
|
|
90
|
+
}
|