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

fix the issue of cursor movement using arrow keys in the search bar for links #104

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion imports/cyto-react-links-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,18 @@ export const CytoReactLinksCard = React.memo<any>(({

useEffect(() => {
inputRef.current.focus();
})
}, []);

const selectLink = useCallback((linkId) => {
setSelectedLink((prevLinkId) => prevLinkId == linkId ? 0 : linkId);
}, []);

useHotkeys('up,right,down,left', e => {
const searchInput = document.activeElement;
if (searchInput instanceof HTMLInputElement || searchInput instanceof HTMLTextAreaElement) {
return;
}
Comment on lines +228 to +231
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searchInput should be renamed to activeElement, because it can be not only searchInput

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We not should use activeElement from document.


e.preventDefault();
e.stopPropagation();
let index = elements.findIndex(e => e.id == selectedLink);
Expand Down