Skip to content

Commit 8cbf1c5

Browse files
zktzkt
authored andcommitted
refactor: optimize logic and reset refs based on review
1 parent da17a42 commit 8cbf1c5

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/Dialog/index.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,24 +132,18 @@ const Dialog: React.FC<IDialogPropTypes> = (props) => {
132132
}
133133

134134
function onModulesMouseDownCapture(e: React.MouseEvent) {
135-
if (e.target === wrapperRef.current) {
136-
mouseDownOnMaskRef.current = true;
137-
} else {
138-
mouseDownOnMaskRef.current = false;
139-
}
135+
mouseDownOnMaskRef.current = e.target === wrapperRef.current;
140136
}
141137

142138
function onModulesMouseUpCapture(e: React.MouseEvent) {
143-
if (e.target === wrapperRef.current) {
144-
mouseUpOnMaskRef.current = true;
145-
} else {
146-
mouseUpOnMaskRef.current = false;
147-
}
139+
mouseUpOnMaskRef.current = e.target === wrapperRef.current;
148140
}
149141

150142
// ========================= Effect =========================
151143
useEffect(() => {
152144
if (visible) {
145+
mouseDownOnMaskRef.current = false;
146+
mouseUpOnMaskRef.current = false;
153147
setAnimatedVisible(true);
154148
saveLastOutSideActiveElementRef();
155149

0 commit comments

Comments
 (0)