MCPcopy Create free account
hub / github.com/microsoft/SandDance / useFocusRects

Function useFocusRects

docs/app/js/sanddance-app.js:25376–25400  ·  view source on GitHub ↗
(rootRef)

Source from the content-addressed store, hash-verified

25374 return newValue;
25375}
25376function useFocusRects(rootRef) {
25377 _react.useEffect(function() {
25378 var _a1, _b;
25379 var win = (0, _getWindow.getWindow)((_a1 = rootRef) === null || _a1 === void 0 ? void 0 : _a1.current);
25380 if (!win || ((_b = win.FabricConfig) === null || _b === void 0 ? void 0 : _b.disableFocusRects) === true) return undefined;
25381 var count = setMountCounters(win, 1);
25382 if (count <= 1) {
25383 win.addEventListener("mousedown", _onMouseDown, true);
25384 win.addEventListener("pointerdown", _onPointerDown, true);
25385 win.addEventListener("keydown", _onKeyDown, true);
25386 }
25387 return function() {
25388 var _a;
25389 if (!win || ((_a = win.FabricConfig) === null || _a === void 0 ? void 0 : _a.disableFocusRects) === true) return;
25390 count = setMountCounters(win, -1);
25391 if (count === 0) {
25392 win.removeEventListener("mousedown", _onMouseDown, true);
25393 win.removeEventListener("pointerdown", _onPointerDown, true);
25394 win.removeEventListener("keydown", _onKeyDown, true);
25395 }
25396 };
25397 }, [
25398 rootRef
25399 ]);
25400}
25401var FocusRects = function(props) {
25402 useFocusRects(props.rootRef);
25403 return null;

Callers 1

FocusRectsFunction · 0.85

Calls 1

setMountCountersFunction · 0.85

Tested by

no test coverage detected