You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
593 B
24 lines
593 B
import { watch, isRef } from 'vue';
|
|
|
|
const useRestoreActive = (toggle, initialFocus) => {
|
|
let previousActive;
|
|
watch(() => toggle.value, (val) => {
|
|
var _a, _b;
|
|
if (val) {
|
|
previousActive = document.activeElement;
|
|
if (isRef(initialFocus)) {
|
|
(_b = (_a = initialFocus.value).focus) == null ? void 0 : _b.call(_a);
|
|
}
|
|
} else {
|
|
if (process.env.NODE_ENV === "test") {
|
|
previousActive.focus.call(previousActive);
|
|
} else {
|
|
previousActive.focus();
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
export { useRestoreActive };
|
|
//# sourceMappingURL=index.mjs.map
|