From a044c51163bf8008b1aa480206492369fee9d944 Mon Sep 17 00:00:00 2001 From: Darcy Ye Date: Wed, 29 Nov 2023 22:54:32 +0800 Subject: [PATCH] chore(console): put description under email domain field (#5005) --- .../Experience/MultiInput/index.module.scss | 12 +- .../Experience/MultiInput/index.tsx | 173 +++++++++--------- .../Experience/index.module.scss | 6 - .../EnterpriseSsoDetails/Experience/index.tsx | 7 +- 4 files changed, 102 insertions(+), 96 deletions(-) diff --git a/packages/console/src/pages/EnterpriseSsoDetails/Experience/MultiInput/index.module.scss b/packages/console/src/pages/EnterpriseSsoDetails/Experience/MultiInput/index.module.scss index af6108618..e83d6fad3 100644 --- a/packages/console/src/pages/EnterpriseSsoDetails/Experience/MultiInput/index.module.scss +++ b/packages/console/src/pages/EnterpriseSsoDetails/Experience/MultiInput/index.module.scss @@ -70,10 +70,18 @@ border-color: var(--color-primary); outline-color: var(--color-focused-variant); } + + &.error { + border-color: var(--color-error); + + &:focus-within { + outline-color: var(--color-danger-focused); + } + } } -.error { - border-color: var(--color-error); +.errorMessage { font: var(--font-body-2); + color: var(--color-error); margin-top: _.unit(1); } diff --git a/packages/console/src/pages/EnterpriseSsoDetails/Experience/MultiInput/index.tsx b/packages/console/src/pages/EnterpriseSsoDetails/Experience/MultiInput/index.tsx index f0dbb3b63..c24ccc768 100644 --- a/packages/console/src/pages/EnterpriseSsoDetails/Experience/MultiInput/index.tsx +++ b/packages/console/src/pages/EnterpriseSsoDetails/Experience/MultiInput/index.tsx @@ -64,92 +64,97 @@ function MultiInput({ className, values, onChange, error, placeholder }: Props) }; return ( -
{ - inputRef.current?.focus(); - })} - onClick={() => { - inputRef.current?.focus(); - }} - > - {values.map((option) => { - return ( - { - inputRef.current?.focus(); - }} - > - {option.value} - { - handleDelete(option); - }} - onKeyDown={onKeyDownHandler(() => { - handleDelete(option); - })} - > - - - - ); - })} - { - if (event.key === 'Backspace' && currentValue === '') { - if (focusedValueId) { - onChange(values.filter(({ id }) => id !== focusedValueId)); - setFocusedValueId(null); - } else { - setFocusedValueId(values.at(-1)?.id ?? null); - } - inputRef.current?.focus(); - } - if (event.key === ' ' || event.code === 'Space' || event.key === 'Enter') { - // Focusing on input - if (currentValue !== '' && document.activeElement === inputRef.current) { - handleAdd(currentValue); - } - // Do not react to "Enter" - event.preventDefault(); - } - }} - onChange={({ currentTarget: { value } }) => { - setCurrentValue(value); - setFocusedValueId(null); - }} - onFocus={() => { + <> +
{ + inputRef.current?.focus(); + })} + onClick={() => { inputRef.current?.focus(); }} - onBlur={() => { - if (currentValue !== '') { - handleAdd(currentValue); - } - setFocusedValueId(null); - }} - /> -
+ > + {values.map((option) => { + return ( + { + inputRef.current?.focus(); + }} + > + {option.value} + { + handleDelete(option); + }} + onKeyDown={onKeyDownHandler(() => { + handleDelete(option); + })} + > + + + + ); + })} + { + if (event.key === 'Backspace' && currentValue === '') { + if (focusedValueId) { + onChange(values.filter(({ id }) => id !== focusedValueId)); + setFocusedValueId(null); + } else { + setFocusedValueId(values.at(-1)?.id ?? null); + } + inputRef.current?.focus(); + } + if (event.key === ' ' || event.code === 'Space' || event.key === 'Enter') { + // Focusing on input + if (currentValue !== '' && document.activeElement === inputRef.current) { + handleAdd(currentValue); + } + // Do not react to "Enter" + event.preventDefault(); + } + }} + onChange={({ currentTarget: { value } }) => { + setCurrentValue(value); + setFocusedValueId(null); + }} + onFocus={() => { + inputRef.current?.focus(); + }} + onBlur={() => { + if (currentValue !== '') { + handleAdd(currentValue); + } + setFocusedValueId(null); + }} + /> +
+ {Boolean(error) && typeof error === 'string' && ( +
{error}
+ )} + ); } diff --git a/packages/console/src/pages/EnterpriseSsoDetails/Experience/index.module.scss b/packages/console/src/pages/EnterpriseSsoDetails/Experience/index.module.scss index cdb2f36d4..7ebcb4baa 100644 --- a/packages/console/src/pages/EnterpriseSsoDetails/Experience/index.module.scss +++ b/packages/console/src/pages/EnterpriseSsoDetails/Experience/index.module.scss @@ -3,12 +3,6 @@ .description { color: var(--color-text-secondary); font: var(--font-body-2); - margin-bottom: _.unit(1); -} - -.errorMessage { - font: var(--font-body-2); - color: var(--color-error); margin-top: _.unit(1); } diff --git a/packages/console/src/pages/EnterpriseSsoDetails/Experience/index.tsx b/packages/console/src/pages/EnterpriseSsoDetails/Experience/index.tsx index 14cccf6a3..d89170c4b 100644 --- a/packages/console/src/pages/EnterpriseSsoDetails/Experience/index.tsx +++ b/packages/console/src/pages/EnterpriseSsoDetails/Experience/index.tsx @@ -179,9 +179,6 @@ function Experience({ data, isDeleted, onUpdated }: Props) { )} -
- {t('enterprise_sso_details.email_domain_field_description')} -
)} /> - {errors.domains &&
{errors.domains.message}
} +
+ {t('enterprise_sso_details.email_domain_field_description')} +