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: TxFlow submit button alignment, error message spacing #2227

Merged
merged 2 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/tx-flow/common/TxLayout/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
margin-top: var(--space-3);
}

.step :global(.MuiCardActions-root) button[type='submit'] {
.step :global(.MuiCardActions-root) > * {
align-self: flex-end;
}

Expand Down
35 changes: 20 additions & 15 deletions src/components/tx/SignOrExecuteForm/ExecuteForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const ExecuteForm = ({
}

const submitDisabled = !safeTx || !isSubmittable || disableSubmit || isValidExecutionLoading || isExecutionLoop
const hasError = isExecutionLoop || executionValidationError || gasLimitError || submitError

return (
<>
Expand All @@ -122,21 +123,25 @@ const ExecuteForm = ({
)}

{/* Error messages */}
{isExecutionLoop ? (
<ErrorMessage>
Cannot execute a transaction from the Safe Account itself, please connect a different account.
</ErrorMessage>
) : executionValidationError || gasLimitError ? (
<ErrorMessage error={executionValidationError || gasLimitError}>
This transaction will most likely fail.{' '}
{isNewExecutableTx
? 'To save gas costs, avoid creating the transaction.'
: 'To save gas costs, reject this transaction.'}
</ErrorMessage>
) : (
submitError && (
<ErrorMessage error={submitError}>Error submitting the transaction. Please try again.</ErrorMessage>
)
{hasError && (
<div className={css.errorWrapper}>
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if it's better or worse but if you pass the className to the ErrorMessage components, you need not create the hasError flag. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice, I didn't see that we could already pass a className to ErrorMessage. Lets do it that way so we can remove hasError.

{isExecutionLoop ? (
<ErrorMessage>
Cannot execute a transaction from the Safe Account itself, please connect a different account.
</ErrorMessage>
) : executionValidationError || gasLimitError ? (
<ErrorMessage error={executionValidationError || gasLimitError}>
This transaction will most likely fail.{' '}
{isNewExecutableTx
? 'To save gas costs, avoid creating the transaction.'
: 'To save gas costs, reject this transaction.'}
</ErrorMessage>
) : (
submitError && (
<ErrorMessage error={submitError}>Error submitting the transaction. Please try again.</ErrorMessage>
)
)}
</div>
)}

<Divider className={commonCss.nestedDivider} sx={{ pt: 3 }} />
Expand Down
4 changes: 4 additions & 0 deletions src/components/tx/SignOrExecuteForm/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@
border-top-left-radius: 0 !important;
border-top-right-radius: 0 !important;
}

.errorWrapper {
margin-top: var(--space-2);
}
Loading