-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #231 from oaknational/rc-2024-10-15
build: release
- Loading branch information
Showing
22 changed files
with
786 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export function getRootErrorCause(error: unknown) { | ||
if (!(error instanceof Error)) { | ||
return error; | ||
} | ||
if ("cause" in error && error.cause) { | ||
return getRootErrorCause(error.cause); | ||
} | ||
return error; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,33 @@ | ||
import { useRef, type RefObject } from 'react' | ||
import { useRef, type RefObject } from "react"; | ||
|
||
export function useEnterSubmit(): { | ||
formRef: RefObject<HTMLFormElement> | ||
onKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void | ||
formRef: RefObject<HTMLFormElement>; | ||
onKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void; | ||
} { | ||
const formRef = useRef<HTMLFormElement>(null) | ||
const formRef = useRef<HTMLFormElement>(null); | ||
|
||
const handleKeyDown = ( | ||
event: React.KeyboardEvent<HTMLTextAreaElement> | ||
event: React.KeyboardEvent<HTMLTextAreaElement>, | ||
): void => { | ||
if ( | ||
event.key === 'Enter' && | ||
event.key === "Enter" && | ||
!event.shiftKey && | ||
!event.nativeEvent.isComposing | ||
) { | ||
formRef.current?.requestSubmit() | ||
event.preventDefault() | ||
try { | ||
if (formRef.current?.requestSubmit) { | ||
formRef.current.requestSubmit(); | ||
} else if (formRef.current?.submit) { | ||
formRef.current.submit(); | ||
} else { | ||
throw new Error("Form submission not supported"); | ||
} | ||
} catch (error) { | ||
console.error("Failed to submit form:", error); | ||
} | ||
event.preventDefault(); | ||
} | ||
} | ||
}; | ||
|
||
return { formRef, onKeyDown: handleKeyDown } | ||
return { formRef, onKeyDown: handleKeyDown }; | ||
} |
Oops, something went wrong.