Skip to content

Commit

Permalink
Hotfix: only open the form dialog for the selected validator info (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepinho authored Mar 5, 2024
1 parent 301f562 commit 13a18a4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const FormDialog = ({
amount,
delegationTokens,
unstakedTokens,
open,
onChangeAmount,
onClose,
onSubmit,
Expand All @@ -45,6 +46,10 @@ export const FormDialog = ({
* Used to show the user how many tokens they have available to delegate.
*/
unstakedTokens?: ValueView;
/**
* Whether the form is open.
*/
open: boolean;
onChangeAmount: (amount: string) => void;
onClose: () => void;
onSubmit: () => void;
Expand All @@ -59,9 +64,9 @@ export const FormDialog = ({
};

return (
<Dialog open={!!action} onOpenChange={handleOpenChange}>
<Dialog open={open} onOpenChange={handleOpenChange}>
<DialogContent size='sm'>
{!!action && (
{!!open && !!action && (
<>
<DialogHeader>{getCapitalizedAction(action)}</DialogHeader>
<form className='flex flex-col gap-4 overflow-hidden px-4 pb-4' onSubmit={handleSubmit}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@ export const StakingActions = ({
*/
unstakedTokens?: ValueView;
}) => {
const { action, amount, onClickActionButton, delegate, undelegate, onClose, setAmount } =
useStore(stakingSelector);
const {
action,
amount,
onClickActionButton,
delegate,
undelegate,
onClose,
setAmount,
validatorInfo: selectedValidatorInfo,
} = useStore(stakingSelector);

const validator = getValidator(validatorInfo);

Expand Down Expand Up @@ -73,6 +81,7 @@ export const StakingActions = ({

<FormDialog
action={action}
open={!!action && validator.equals(getValidator(selectedValidatorInfo))}
validator={validator}
amount={amount}
delegationTokens={delegationTokens}
Expand Down

0 comments on commit 13a18a4

Please sign in to comment.