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

RENO-4325: Disabling the submit button when the form is submitted #252

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/components/ReviewFormContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ function ReviewFormContainer() {

<FormRow margin-top="20px">
<DSFormField>
<RoutingLinks next={{ submit: true, text: t("button.submit") }} />
<RoutingLinks isDisabled={isLoading} next={{ submit: true, text: t("button.submit") }} />
</DSFormField>
</FormRow>
</Form>
Expand Down
8 changes: 7 additions & 1 deletion src/components/RoutingLinks.tsx/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface RoutingLinksType {
// We only want an optional "submit" property for the next prop.
// The "url" and "text" props are not needed if "submit" is passed.
next: Partial<LinkType> & { submit?: boolean };
isDisabled?: boolean;
}

/**
Expand All @@ -27,7 +28,11 @@ export interface RoutingLinksType {
* previous link is optional so it can be used on the starting page. A simple
* approach to routing until submitting forms is integrated into routing.
*/
function RoutingLinks({ previous, next }: RoutingLinksType): JSX.Element {
function RoutingLinks({
previous,
next,
isDisabled = false,
}: RoutingLinksType): JSX.Element {
const { t } = useTranslation("common");
const nextText = next.text || t("button.next");
const previousText = previous?.text || t("button.previous");
Expand Down Expand Up @@ -63,6 +68,7 @@ function RoutingLinks({ previous, next }: RoutingLinksType): JSX.Element {
) : (
<input
className={`button ${styles.next}`}
disabled={isDisabled}
type="submit"
value={nextText}
/>
Expand Down
Loading