mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-24 07:02:26 +01:00
BUGFIX: Prevent runtime NotAllowedError on Safari (#1507)
Could occur when the browser’s window is resized.
This commit is contained in:
parent
4502fd443e
commit
42bcfa1889
@ -94,7 +94,11 @@ export function Overview({ children, mode }: IProps): React.ReactElement {
|
|||||||
triggerMouseEvent(node, "mousedown");
|
triggerMouseEvent(node, "mousedown");
|
||||||
triggerMouseEvent(document, "mousemove");
|
triggerMouseEvent(document, "mousemove");
|
||||||
triggerMouseEvent(node, "mouseup");
|
triggerMouseEvent(node, "mouseup");
|
||||||
triggerMouseEvent(node, "click");
|
// According to a comment in the above GitHub issue, apparently mousemove is important,
|
||||||
|
// but click probably isn't. This click causes a runtime error in Safari (NotAllowedError),
|
||||||
|
// but not Chromium. If further errors occur, a more thorough fix, possibly using
|
||||||
|
// navigator.userActivation.isActive, might be necessary.
|
||||||
|
// triggerMouseEvent(node, "click");
|
||||||
}, 100),
|
}, 100),
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
@ -111,8 +115,7 @@ export function Overview({ children, mode }: IProps): React.ReactElement {
|
|||||||
}, [fakeDrag]);
|
}, [fakeDrag]);
|
||||||
|
|
||||||
const triggerMouseEvent = (node: HTMLDivElement | Document, eventType: string): void => {
|
const triggerMouseEvent = (node: HTMLDivElement | Document, eventType: string): void => {
|
||||||
const clickEvent = document.createEvent("MouseEvents");
|
const clickEvent = new MouseEvent(eventType, { bubbles: true, cancelable: true });
|
||||||
clickEvent.initEvent(eventType, true, true);
|
|
||||||
node.dispatchEvent(clickEvent);
|
node.dispatchEvent(clickEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user