From 6779a9f15fa82ba574362b1d10f6cebf1bfdde2a Mon Sep 17 00:00:00 2001 From: Xiao Yijun Date: Wed, 1 Feb 2023 12:50:52 +0800 Subject: [PATCH] refactor(console): use overlay scrollbar in dropdown (#3035) --- .../src/components/Dropdown/DropdownItem.module.scss | 1 - .../console/src/components/Dropdown/DropdownItem.tsx | 8 ++++---- .../console/src/components/Dropdown/index.module.scss | 5 ----- packages/console/src/components/Dropdown/index.tsx | 7 ++++--- .../LanguageEditor/AddLanguageSelector.module.scss | 2 -- .../LanguageEditor/AddLanguageSelector.tsx | 9 +++++---- packages/integration-tests/src/tests/ui/smoke.test.ts | 4 +++- 7 files changed, 16 insertions(+), 20 deletions(-) diff --git a/packages/console/src/components/Dropdown/DropdownItem.module.scss b/packages/console/src/components/Dropdown/DropdownItem.module.scss index 66f4cae6a..26c991019 100644 --- a/packages/console/src/components/Dropdown/DropdownItem.module.scss +++ b/packages/console/src/components/Dropdown/DropdownItem.module.scss @@ -3,7 +3,6 @@ .item { padding: _.unit(2); border-radius: _.unit(2); - list-style: none; font: var(--font-body-medium); cursor: pointer; display: flex; diff --git a/packages/console/src/components/Dropdown/DropdownItem.tsx b/packages/console/src/components/Dropdown/DropdownItem.tsx index 885bfd3fd..7e53d4c5a 100644 --- a/packages/console/src/components/Dropdown/DropdownItem.tsx +++ b/packages/console/src/components/Dropdown/DropdownItem.tsx @@ -6,7 +6,7 @@ import { onKeyDownHandler } from '@/utilities/a11y'; import * as styles from './DropdownItem.module.scss'; type Props = { - onClick?: (event: MouseEvent | KeyboardEvent) => void; + onClick?: (event: MouseEvent | KeyboardEvent) => void; className?: string; children: ReactNode | Record; icon?: ReactNode; @@ -22,16 +22,16 @@ const DropdownItem = ({ iconClassName, type = 'default', }: Props) => ( -
  • {icon && {icon}} {children} -
  • + ); export default DropdownItem; diff --git a/packages/console/src/components/Dropdown/index.module.scss b/packages/console/src/components/Dropdown/index.module.scss index 4e3221bee..406ec59bb 100644 --- a/packages/console/src/components/Dropdown/index.module.scss +++ b/packages/console/src/components/Dropdown/index.module.scss @@ -29,8 +29,3 @@ position: fixed; inset: 0; } - -.list { - margin: 0; - overflow-y: auto; -} diff --git a/packages/console/src/components/Dropdown/index.tsx b/packages/console/src/components/Dropdown/index.tsx index 6c952167e..8f3a721a3 100644 --- a/packages/console/src/components/Dropdown/index.tsx +++ b/packages/console/src/components/Dropdown/index.tsx @@ -7,6 +7,7 @@ import usePosition from '@/hooks/use-position'; import type { HorizontalAlignment } from '@/types/positioning'; import { onKeyDownHandler } from '@/utilities/a11y'; +import OverlayScrollbar from '../OverlayScrollbar'; import * as styles from './index.module.scss'; export { default as DropdownItem } from './DropdownItem'; @@ -65,15 +66,15 @@ const Dropdown = ({ >
    {title &&
    {title}
    } -
      {children} -
    +
    ); diff --git a/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/AddLanguageSelector.module.scss b/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/AddLanguageSelector.module.scss index c24f9c293..113bfe761 100644 --- a/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/AddLanguageSelector.module.scss +++ b/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/AddLanguageSelector.module.scss @@ -27,12 +27,10 @@ overflow-y: auto; box-shadow: var(--shadow-2); - .dropDownItem { width: 100%; border-radius: _.unit(2); padding: _.unit(2); - list-style: none; cursor: pointer; font: var(--font-body-medium); diff --git a/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/AddLanguageSelector.tsx b/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/AddLanguageSelector.tsx index 095392d39..84cf09f2e 100644 --- a/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/AddLanguageSelector.tsx +++ b/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/AddLanguageSelector.tsx @@ -7,6 +7,7 @@ import { useTranslation } from 'react-i18next'; import Plus from '@/assets/images/plus.svg'; import SearchIcon from '@/assets/images/search.svg'; import Button from '@/components/Button'; +import OverlayScrollbar from '@/components/OverlayScrollbar'; import TextInput from '@/components/TextInput'; import { onKeyDownHandler } from '@/utilities/a11y'; @@ -89,9 +90,9 @@ const AddLanguageSelector = ({ options, onSelect }: Props) => { )} {isDropDownOpen && filteredOptions.length > 0 && ( -
      + {filteredOptions.map((languageTag) => ( -
    • { >
      {uiLanguageNameMapping[languageTag]}
      {languageTag}
      -
    • + ))} -
    + )} ); diff --git a/packages/integration-tests/src/tests/ui/smoke.test.ts b/packages/integration-tests/src/tests/ui/smoke.test.ts index bcf18604a..02c61cf2b 100644 --- a/packages/integration-tests/src/tests/ui/smoke.test.ts +++ b/packages/integration-tests/src/tests/ui/smoke.test.ts @@ -55,7 +55,9 @@ describe('smoke testing', () => { // Try awaiting for 500ms before clicking sign-out button await page.waitForTimeout(500); - const signOutButton = await page.waitForSelector('.ReactModalPortal ul li'); + const signOutButton = await page.waitForSelector( + '.ReactModalPortal div[class$=dropdownContainer] div[class$=dropdownItem]' + ); const navigation = page.waitForNavigation({ waitUntil: 'networkidle0' }); await signOutButton.click(); await navigation;