-
-
Notifications
You must be signed in to change notification settings - Fork 650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
web: add go to next/previous tab shortcut #7109
base: master
Are you sure you want to change the base?
Conversation
85ba203
to
66b7340
Compare
handleKeyDown(_, event) { | ||
if (event.ctrlKey && event.key === "ArrowRight") { | ||
event.preventDefault(); | ||
useEditorStore.getState().openNextSession("right"); | ||
} | ||
if (event.ctrlKey && event.key === "ArrowLeft") { | ||
event.preventDefault(); | ||
useEditorStore.getState().openNextSession("left"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this is the right place to handle this. Also Ctrl + Arrow Keys are used for caret navigation so we can't use those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch on the Ctrl + Arrow shortcut. I've moved this shortcut to Ctrl + Alt + Arrow, let me know if this is okayy
if (isActive) { | ||
activeTabRef.current = el; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to wrap this in a condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the condition, the tab strip would scroll to the last tab regardless of the active tab position.
Signed-off-by: 01zulfi <[email protected]>
66b7340
to
1f8dc53
Compare
useEffect(() => { | ||
const onKeyDown = (event: KeyboardEvent) => { | ||
if (event.ctrlKey && event.altKey && event.key === "ArrowRight") { | ||
event.preventDefault(); | ||
useEditorStore.getState().openNextSession(); | ||
} | ||
if (event.ctrlKey && event.altKey && event.key === "ArrowLeft") { | ||
event.preventDefault(); | ||
useEditorStore.getState().openPreviousSession(); | ||
} | ||
}; | ||
document.body.addEventListener("keydown", onKeyDown); | ||
return () => { | ||
document.body.removeEventListener("keydown", onKeyDown); | ||
}; | ||
}, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved the onKeyDown
handler for this keyboard shortcut here as I noticed that the readonly
notes weren't handled.
Signed-off-by: 01zulfi [email protected]