Closed
Description
Which component is affected?
Qwik Runtime
Describe the bug
useTask$(({ cleanup }) => {
const handleKeyPress = (e) => {
if (e.key === "`" && e.metaKey) {
state.isOpen.value = !state.isOpen.value;
}
if (e.key === "Escape" && state.isOpen.value) {
state.isOpen.value = false;
}
};
const handleClickOutside = (e) => {
if (state.isOpen.value && panelRef.value && !panelRef.value.contains(e.target)) {
state.isOpen.value = false;
}
};
if (!isBrowser) return;
window.addEventListener("keydown", handleKeyPress);
window.addEventListener("mousedown", handleClickOutside);
cleanup(() => {
window.removeEventListener("keydown", handleKeyPress);
window.removeEventListener("mousedown", handleClickOutside);
});
});
if this useTask executes in server end, but which includes some client codes, and then the terminals will throws an error.
I'd better we could give a tips for user.
something likes "Please wrap the code with isBrowser to ensure it only runs on the client side."
Reproduction
Steps to reproduce
No response
System Info
latest
Additional Information
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done