43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
/*
|
|
* Extracted from browser-delivered Turbopack chunk: 20293dbce215808d.10cf9e27a9.js
|
|
* Module id: 201774
|
|
* For reading/searching only; this factory depends on the original Turbopack runtime.
|
|
*/
|
|
|
|
const moduleFactory = (e) => {
|
|
"use strict";
|
|
var t = e.i(358379),
|
|
n = e.i(361752);
|
|
function r({ opened: e, shouldReturnFocus: r = !0 }) {
|
|
let o = (0, t.useRef)(null),
|
|
i = () => {
|
|
o.current &&
|
|
"focus" in o.current &&
|
|
"function" == typeof o.current.focus &&
|
|
o.current?.focus({ preventScroll: !0 });
|
|
};
|
|
return (
|
|
(0, n.useDidUpdate)(() => {
|
|
let t = -1,
|
|
n = (e) => {
|
|
"Tab" === e.key && window.clearTimeout(t);
|
|
};
|
|
return (
|
|
document.addEventListener("keydown", n),
|
|
e
|
|
? (o.current = document.activeElement)
|
|
: r && (t = window.setTimeout(i, 10)),
|
|
() => {
|
|
window.clearTimeout(t),
|
|
document.removeEventListener("keydown", n);
|
|
}
|
|
);
|
|
}, [e, r]),
|
|
i
|
|
);
|
|
}
|
|
e.s(["useFocusReturn", () => r]);
|
|
};
|
|
|
|
export default moduleFactory;
|