Skip to content

Commit

Permalink
feat: add keyboard binding for posting a highlight (#1894)
Browse files Browse the repository at this point in the history
  • Loading branch information
RitaDee authored Oct 16, 2023
1 parent f61d930 commit 346adff
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/molecules/HighlightInput/highlight-input-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,9 @@ const HighlightInputForm = ({ refreshCallback }: HighlightInputFormProps): JSX.E
};

// Handle submit highlights
const handlePostHighlight = async (e: React.FormEvent<HTMLFormElement>) => {
const handlePostHighlight = async (
e: React.FormEvent<HTMLFormElement> | React.KeyboardEvent<HTMLTextAreaElement>
) => {
e.preventDefault();

const highlight = bodyText;
Expand Down Expand Up @@ -520,6 +522,11 @@ const HighlightInputForm = ({ refreshCallback }: HighlightInputFormProps): JSX.E
}`}
defaultRow={4}
value={bodyText}
onKeyUp={(e) => {
if (e.ctrlKey && e.key === "Enter") {
handlePostHighlight(e);
}
}}
placeholder={`Tell us about your highlight and add a link
`}
typewrite={isTyping}
Expand Down

0 comments on commit 346adff

Please sign in to comment.