-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
COMMUNITY: good first issueGood for newcomersGood for newcomersCOMMUNITY: PR is welcomedWe think it's a good feature to have but would love for the community to help with the PR for itWe think it's a good feature to have but would love for the community to help with the PR for itCOMP: DXDeveloper Experience related issueDeveloper Experience related issueTYPE: bugSomething isn't workingSomething isn't working
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
latestAdditional Information
No response
thejackshelton and JerryWu1234
Metadata
Metadata
Assignees
Labels
COMMUNITY: good first issueGood for newcomersGood for newcomersCOMMUNITY: PR is welcomedWe think it's a good feature to have but would love for the community to help with the PR for itWe think it's a good feature to have but would love for the community to help with the PR for itCOMP: DXDeveloper Experience related issueDeveloper Experience related issueTYPE: bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done
