Skip to content

Commit 09c14c6

Browse files
[Misc] ios memory api 11.9 (#12270)
(r11.9 → 11.9)
1 parent 8461e60 commit 09c14c6

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/components/DocumentContainer/DocumentContainer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class DocumentContainer extends React.PureComponent {
117117
}
118118

119119
if (process.env.NODE_ENV === 'development') {
120-
this.container.current.addEventListener('dragover', this.preventDefault);
120+
this.container.current.removeEventListener('dragover', this.preventDefault);
121121
this.container.current.removeEventListener('drop', this.onDrop);
122122
}
123123

src/components/Tooltip/Tooltip.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const Tooltip = forwardRef(({ content = '', children, hideShortcut, forcePositio
2929
const timeoutRef = useRef(null);
3030
const hiddenByClickRef = useRef(false);
3131
const childRef = useRef(null);
32+
const showRef = useRef(false); // track current show state to avoid redundant enqueues from high-frequency pointermove
33+
const opacityRef = useRef(0); // track current opacity to avoid redundant enqueues
3234
useImperativeHandle(ref, () => childRef.current);
3335
const isDisabled = useSelector((state) => selectors.isElementDisabled(state, 'tooltip'));
3436

@@ -44,6 +46,20 @@ const Tooltip = forwardRef(({ content = '', children, hideShortcut, forcePositio
4446
const delayShow = 300;
4547
const opacityTimeout = 50;
4648

49+
const setShowGuarded = (value) => {
50+
if (showRef.current !== value) {
51+
showRef.current = value;
52+
setShow(value);
53+
}
54+
};
55+
56+
const setOpacityGuarded = (value) => {
57+
if (opacityRef.current !== value) {
58+
opacityRef.current = value;
59+
setOpacity(value);
60+
}
61+
};
62+
4763
useEffect(() => {
4864
const showToolTip = () => {
4965
clearTimeout(timeoutRef.current);
@@ -52,14 +68,15 @@ const Tooltip = forwardRef(({ content = '', children, hideShortcut, forcePositio
5268
}
5369
timeoutRef.current = setTimeout(() => {
5470
setCloseToolTipFunc(hideByClick);
55-
setShow(true);
71+
setShowGuarded(true);
5672
fireEvent(Events.TOOLTIP_OPENED);
5773
}, delayShow - opacityTimeout);
5874
};
5975

6076
const hideTooltip = () => {
6177
clearTimeout(timeoutRef.current);
62-
setShow(false);
78+
setShowGuarded(false);
79+
setOpacityGuarded(0);
6380
};
6481

6582
const hideByBlur = () => {
@@ -208,10 +225,10 @@ const Tooltip = forwardRef(({ content = '', children, hideShortcut, forcePositio
208225
if (show && childEle && tooltipEle) {
209226
setTopAndLeft();
210227
setTimeout(() => {
211-
setOpacity(1);
228+
setOpacityGuarded(1);
212229
}, opacityTimeout);
213230
} else {
214-
setOpacity(0);
231+
setOpacityGuarded(0);
215232
}
216233
}, [childRef, show]);
217234

0 commit comments

Comments
 (0)