diff --git a/packages/app-staking/src/Actions/Account/Nominate.tsx b/packages/app-staking/src/Actions/Account/Nominate.tsx index b2ea2d9168..fdbc81790a 100644 --- a/packages/app-staking/src/Actions/Account/Nominate.tsx +++ b/packages/app-staking/src/Actions/Account/Nominate.tsx @@ -19,13 +19,24 @@ interface Props extends I18nProps { stashOptions: KeyringSectionOption[]; } +// We only allow a maximum of 16 nominees, negative to slice +const MAX_NOMINEES = -16; + function Nominate ({ controllerId, isOpen, onClose, stashId, stashOptions, t }: Props): React.ReactElement | null { - const [nominees, setNominees] = useState(); + const [nominees, setNominees] = useState([]); if (!isOpen) { return null; } + const _onChangeNominees = (_nominees: string[]): void => { + const newNominees = _nominees.slice(MAX_NOMINEES); + + if (JSON.stringify(newNominees) !== JSON.stringify(nominees)) { + setNominees(newNominees); + } + }; + return ( @@ -72,7 +84,7 @@ function Nominate ({ controllerId, isOpen, onClose, stashId, stashOptions, t }: & { }; interface State { - value?: string; + value?: string | string[]; } const STORAGE_KEY = 'options:InputAddress'; @@ -187,8 +187,8 @@ class InputAddress extends React.PureComponent { } style={style} value={ - isMultiple - ? undefined + isMultiple && !value + ? [] : value } withEllipsis={withEllipsis}