diff --git a/ui/components/app/modals/account-details-modal/account-details-modal.test.js b/ui/components/app/modals/account-details-modal/account-details-modal.test.js index 72bf233c2..7b85c27bb 100644 --- a/ui/components/app/modals/account-details-modal/account-details-modal.test.js +++ b/ui/components/app/modals/account-details-modal/account-details-modal.test.js @@ -24,7 +24,7 @@ describe('Account Details Modal', () => { global.platform = { openTab: jest.fn() }; it('should set account label when changing default account label', () => { - const { queryByTestId } = renderWithProvider( + const { queryByTestId, getByPlaceholderText } = renderWithProvider( , mockStore, ); @@ -35,7 +35,7 @@ describe('Account Details Modal', () => { fireEvent.click(editButton); expect(queryByTestId('editable-input')).toBeInTheDocument(); - const editableInput = queryByTestId('editable-input'); + const editableInput = getByPlaceholderText('Account name'); const newAccountLabel = 'New Label'; fireEvent.change(editableInput, { diff --git a/ui/components/multichain/account-details/account-details-authenticate.js b/ui/components/multichain/account-details/account-details-authenticate.js index 240b618a4..c76bde71b 100644 --- a/ui/components/multichain/account-details/account-details-authenticate.js +++ b/ui/components/multichain/account-details/account-details-authenticate.js @@ -3,8 +3,8 @@ import { useDispatch, useSelector } from 'react-redux'; import PropTypes from 'prop-types'; import { DISPLAY, + FontWeight, SEVERITIES, - TextColor, TextVariant, } from '../../../helpers/constants/design-system'; import { @@ -56,19 +56,10 @@ export const AccountDetailsAuthenticate = ({ address, onCancel }) => { value={password} variant={TextVariant.bodySm} type="password" - inputProps={{ - onKeyPress: handleKeyPress, - }} + inputProps={{ onKeyPress: handleKeyPress }} + labelProps={{ fontWeight: FontWeight.Medium }} + autoFocus /> - {warning ? ( - - {warning} - - ) : null} {t('privateKeyWarning')} diff --git a/ui/components/multichain/account-details/account-details.js b/ui/components/multichain/account-details/account-details.js index 70fa9e862..67244de38 100644 --- a/ui/components/multichain/account-details/account-details.js +++ b/ui/components/multichain/account-details/account-details.js @@ -79,7 +79,10 @@ export const AccountDetails = ({ address }) => { setAttemptingExport(false)} + onClick={() => { + dispatch(hideWarning()); + setAttemptingExport(false); + }} iconName={IconName.ArrowLeft} size={Size.SM} /> diff --git a/ui/components/multichain/account-details/account-details.test.js b/ui/components/multichain/account-details/account-details.test.js index baec78f20..4caed5b0f 100644 --- a/ui/components/multichain/account-details/account-details.test.js +++ b/ui/components/multichain/account-details/account-details.test.js @@ -45,7 +45,7 @@ describe('AccountDetails', () => { const editButton = screen.getByTestId('editable-label-button'); fireEvent.click(editButton); - const editableInput = screen.getByTestId('editable-input'); + const editableInput = screen.getByPlaceholderText('Account name'); const newAccountLabel = 'New Label'; fireEvent.change(editableInput, { target: { value: newAccountLabel } }); diff --git a/ui/components/ui/editable-label/editable-label.js b/ui/components/ui/editable-label/editable-label.js index 7a0558cd8..8e944efec 100644 --- a/ui/components/ui/editable-label/editable-label.js +++ b/ui/components/ui/editable-label/editable-label.js @@ -1,9 +1,20 @@ +import React, { Component } from 'react'; import classnames from 'classnames'; import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { Color } from '../../../helpers/constants/design-system'; +import { + AlignItems, + Color, + DISPLAY, + TextVariant, +} from '../../../helpers/constants/design-system'; import { getAccountNameErrorMessage } from '../../../helpers/utils/accounts'; -import { ButtonIcon, IconName } from '../../component-library'; +import { + ButtonIcon, + FormTextField, + IconName, + Text, +} from '../../component-library'; +import Box from '../box/box'; export default class EditableLabel extends Component { static propTypes = { @@ -40,40 +51,40 @@ export default class EditableLabel extends Component { ); return ( -
- + { if (event.key === 'Enter') { this.handleSubmit(isValidAccountName); } }} - onChange={(event) => this.setState({ value: event.target.value })} + onChange={(event) => { + this.setState({ value: event.target.value }); + }} data-testid="editable-input" - className={classnames('large-input', 'editable-label__input', { - 'editable-label__input--error': !isValidAccountName, - })} + error={!isValidAccountName} + helpText={errorMessage} autoFocus + placeholder={this.context.t('accountName')} /> this.handleSubmit(isValidAccountName)} /> -
- {errorMessage} -
-
+ ); } renderReadonly() { return ( -
-
{this.state.value}
+ + {this.state.value} this.setState({ isEditing: true })} color={Color.iconDefault} /> -
+ ); } diff --git a/ui/components/ui/editable-label/index.scss b/ui/components/ui/editable-label/index.scss deleted file mode 100644 index d4b0b7983..000000000 --- a/ui/components/ui/editable-label/index.scss +++ /dev/null @@ -1,46 +0,0 @@ -.editable-label { - display: flex; - align-items: center; - justify-content: center; - position: relative; - flex-flow: wrap; - - &__value { - max-width: 250px; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } - - &__input { - @include H6; - - color: var(--color-text-default); - background-color: var(--color-background-default); - width: 250px; - text-align: center; - border: 1px solid var(--color-border-default); - - &--error { - border: 1px solid var(--color-error-default); - } - } - - &__icon-button { - margin-left: 10px; - left: 100%; - } - - &__error { - @include H7; - - left: 8px; - color: var(--color-error-default); - width: 100%; - text-align: center; - } - - &__error-amount { - margin-top: 5px; - } -} diff --git a/ui/components/ui/ui-components.scss b/ui/components/ui/ui-components.scss index 9558e3ea4..6f012fb2a 100644 --- a/ui/components/ui/ui-components.scss +++ b/ui/components/ui/ui-components.scss @@ -16,7 +16,6 @@ @import 'definition-list/definition-list'; @import 'dialog/dialog'; @import 'dropdown/dropdown'; -@import 'editable-label/index'; @import 'error-message/index'; @import 'icon-border/icon-border'; @import 'icon-button/icon-button'; diff --git a/ui/helpers/utils/accounts.js b/ui/helpers/utils/accounts.js index 6bfa68d86..4f953bf66 100644 --- a/ui/helpers/utils/accounts.js +++ b/ui/helpers/utils/accounts.js @@ -10,6 +10,8 @@ export function getAccountNameErrorMessage( (item) => item.name === newAccountName, ); + const isEmptyAccountName = newAccountName === ''; + const localizedWordForAccount = context .t('newAccountNumberName') .replace(' $1', ''); @@ -24,7 +26,7 @@ export function getAccountNameErrorMessage( const isValidAccountName = newAccountName === defaultAccountName || // What is written in the text field is the same as the placeholder - (!isDuplicateAccountName && !isReservedAccountName); + (!isDuplicateAccountName && !isReservedAccountName && !isEmptyAccountName); let errorMessage; if (isValidAccountName) { @@ -33,6 +35,8 @@ export function getAccountNameErrorMessage( errorMessage = context.t('accountNameDuplicate'); } else if (isReservedAccountName) { errorMessage = context.t('accountNameReserved'); + } else if (isEmptyAccountName) { + errorMessage = context.t('required'); } return { isValidAccountName, errorMessage };