Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

01zulfi
Copy link
Collaborator

@01zulfi 01zulfi commented Dec 17, 2024

Signed-off-by: 01zulfi [email protected]

@01zulfi 01zulfi force-pushed the feat/switch-tab-shortcut branch from 85ba203 to 66b7340 Compare December 18, 2024 05:34
apps/web/src/stores/editor-store.ts Outdated Show resolved Hide resolved
Comment on lines 168 to 176
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");
}
Copy link
Contributor

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.

Copy link
Collaborator Author

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

Comment on lines +459 to +461
if (isActive) {
activeTabRef.current = el;
}
Copy link
Contributor

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.

Copy link
Collaborator Author

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.

@01zulfi 01zulfi force-pushed the feat/switch-tab-shortcut branch from 66b7340 to 1f8dc53 Compare December 23, 2024 07:27
Comment on lines +124 to +139
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);
};
}, []);
Copy link
Collaborator Author

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.

@01zulfi 01zulfi requested a review from thecodrr December 23, 2024 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants