Skip to content
Open
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
21 changes: 15 additions & 6 deletions src/Generic/components/DialogActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ const useActionButtonStyles = makeStyles((theme) => ({
marginRight: -12
}
},
confirmDialogActionsBox: {
margin: "8px 24px 16px",

[breakpoints.down(600)]: {
justifyContent: "center",
margin: "8px 24px 16px"
}
},
mobileDialogActionsBox: {
display: "flex",
position: "fixed",
Expand Down Expand Up @@ -263,17 +271,18 @@ interface ConfirmDialogProps {
}

export function ConfirmDialog(props: ConfirmDialogProps) {
const isSmallScreen = useIsMobile()
const classes = useActionButtonStyles()

return (
<Dialog open={props.open} onClose={props.onClose} TransitionComponent={CompactDialogTransition}>
<DialogTitle>{props.title}</DialogTitle>
<DialogContent style={{ paddingBottom: isSmallScreen ? 24 : undefined }}>
<DialogContent>
<Typography variant="body2">{props.children}</Typography>
<DialogActionsBox preventMobileActionsBox smallDialog>
{props.cancelButton}
{props.confirmButton}
</DialogActionsBox>
</DialogContent>
<DialogActionsBox className={classes.confirmDialogActionsBox} preventMobileActionsBox smallDialog>
{props.cancelButton}
{props.confirmButton}
</DialogActionsBox>
</Dialog>
)
}
19 changes: 17 additions & 2 deletions src/TransactionReview/components/ReviewForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ function TxConfirmationForm(props: Props) {
const [errors, setErrors] = React.useState<Partial<FormErrors>>({})
const [formValues, setFormValues] = React.useState<FormValues>({ password: null })
const [loading, setLoading] = React.useState<boolean>(false)
const passwordFieldRef = React.useRef<HTMLInputElement | null>(null)
const { t } = useTranslation()

const passwordError = props.passwordError || errors.password
const showPasswordField = props.account.requiresPassword && !props.disabled

const cancelDismissal = React.useCallback(() => setDismissalConfirmationPending(false), [])
const requestDismissalConfirmation = React.useCallback(() => setDismissalConfirmationPending(true), [])
Expand Down Expand Up @@ -169,6 +171,18 @@ function TxConfirmationForm(props: Props) {
}, 0)
}, [])

React.useEffect(() => {
if (!showPasswordField) {
return undefined
}

const animationFrame = window.requestAnimationFrame(() => {
passwordFieldRef.current?.scrollIntoView(false)
})

return () => window.cancelAnimationFrame(animationFrame)
}, [showPasswordField, props.transaction])

return (
<form id={formID} noValidate onSubmit={handleFormSubmission}>
<VerticalLayout>
Expand All @@ -184,7 +198,7 @@ function TxConfirmationForm(props: Props) {
paymentSummary={props.paymentSummary}
paymentSummaryIsEstimated={props.paymentSummaryIsEstimated}
/>
{props.account.requiresPassword && !props.disabled ? (
{showPasswordField ? (
<PasswordField
autoFocus={import.meta.env.VITE_PLATFORM !== "ios"}
error={Boolean(passwordError)}
Expand All @@ -194,14 +208,15 @@ function TxConfirmationForm(props: Props) {
: t("account.transaction-review.textfield.password.label")
}
fullWidth
inputRef={passwordFieldRef}
margin="dense"
value={formValues.password || ""}
onChange={handleTextFieldChange}
style={{ margin: "32px auto 0", maxWidth: 300 }}
/>
) : null}
</VerticalLayout>
<Portal desktop="inline" target={props.actionsRef && props.actionsRef.element}>
<Portal target={props.actionsRef && props.actionsRef.element}>
<DialogActionsBox smallDialog={props.disabled && !props.signatureRequest}>
{props.signatureRequest ? (
<ActionButton icon={DismissIcon} onClick={requestDismissalConfirmation}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function TransactionReviewDialogBody(props: TransactionReviewDialogBodyPr
)

return (
<DialogBody top={titleContent} actions={props.showSubmissionProgress ? null : dialogActionsRef}>
<DialogBody top={titleContent} actions={props.showSubmissionProgress ? null : dialogActionsRef} actionsPosition="bottom">
{props.transaction && !props.showSubmissionProgress ? (
<Box margin={`12px ${isSmallScreen ? "4px" : "0"} 0`} textAlign="center">
<ReviewForm
Expand Down