diff --git a/src/components/Settings/Settings.module.scss b/src/components/Settings/Settings.module.scss index 80880105..98ff07c6 100644 --- a/src/components/Settings/Settings.module.scss +++ b/src/components/Settings/Settings.module.scss @@ -127,6 +127,9 @@ $block: '.#{variables.$ns}settings'; } &__menu { + display: flex; + flex-direction: column; + min-height: 0; border-right: 1px solid var(--g-color-line-generic); } diff --git a/src/components/Settings/SettingsMenu/SettingsMenu.module.scss b/src/components/Settings/SettingsMenu/SettingsMenu.module.scss index 0fd4531f..ce2b9cb1 100644 --- a/src/components/Settings/SettingsMenu/SettingsMenu.module.scss +++ b/src/components/Settings/SettingsMenu/SettingsMenu.module.scss @@ -4,6 +4,12 @@ $block: '.#{variables.$ns}settings-menu'; #{$block} { + overflow-y: auto; + + &_scrolled { + box-shadow: inset 0 5px 5px -5px rgba(0, 0, 0, 0.15); + } + &__group { &-heading { @include mixins.text-accent; diff --git a/src/components/Settings/SettingsMenu/SettingsMenu.tsx b/src/components/Settings/SettingsMenu/SettingsMenu.tsx index c651bb72..79013b11 100644 --- a/src/components/Settings/SettingsMenu/SettingsMenu.tsx +++ b/src/components/Settings/SettingsMenu/SettingsMenu.tsx @@ -19,10 +19,15 @@ export const SettingsMenu = React.forwardRef(); + const [scrolled, setScrolled] = React.useState(false); const containerRef = React.useRef(null); const handleChange = useStableCallback(onChange); const getFocused = useCurrent(focusItemId); + const handleScroll = React.useCallback((event: React.UIEvent) => { + setScrolled(event.currentTarget.scrollTop > 0); + }, []); + React.useImperativeHandle( ref, () => ({ @@ -51,7 +56,7 @@ export const SettingsMenu = React.forwardRef +
{items.map((firstLevelItem) => { if ('groupTitle' in firstLevelItem) { return ( diff --git a/src/components/Settings/__snapshots__/BurgerMenu.visual.test.tsx-snapshots/Settings-render-story-Overflow-dark-chromium-linux.png b/src/components/Settings/__snapshots__/BurgerMenu.visual.test.tsx-snapshots/Settings-render-story-Overflow-dark-chromium-linux.png new file mode 100644 index 00000000..7065a064 Binary files /dev/null and b/src/components/Settings/__snapshots__/BurgerMenu.visual.test.tsx-snapshots/Settings-render-story-Overflow-dark-chromium-linux.png differ diff --git a/src/components/Settings/__snapshots__/BurgerMenu.visual.test.tsx-snapshots/Settings-render-story-Overflow-dark-webkit-linux.png b/src/components/Settings/__snapshots__/BurgerMenu.visual.test.tsx-snapshots/Settings-render-story-Overflow-dark-webkit-linux.png new file mode 100644 index 00000000..cfa5eeb6 Binary files /dev/null and b/src/components/Settings/__snapshots__/BurgerMenu.visual.test.tsx-snapshots/Settings-render-story-Overflow-dark-webkit-linux.png differ diff --git a/src/components/Settings/__snapshots__/BurgerMenu.visual.test.tsx-snapshots/Settings-render-story-Overflow-light-chromium-linux.png b/src/components/Settings/__snapshots__/BurgerMenu.visual.test.tsx-snapshots/Settings-render-story-Overflow-light-chromium-linux.png new file mode 100644 index 00000000..fe0455d5 Binary files /dev/null and b/src/components/Settings/__snapshots__/BurgerMenu.visual.test.tsx-snapshots/Settings-render-story-Overflow-light-chromium-linux.png differ diff --git a/src/components/Settings/__snapshots__/BurgerMenu.visual.test.tsx-snapshots/Settings-render-story-Overflow-light-webkit-linux.png b/src/components/Settings/__snapshots__/BurgerMenu.visual.test.tsx-snapshots/Settings-render-story-Overflow-light-webkit-linux.png new file mode 100644 index 00000000..b1a38ff1 Binary files /dev/null and b/src/components/Settings/__snapshots__/BurgerMenu.visual.test.tsx-snapshots/Settings-render-story-Overflow-light-webkit-linux.png differ diff --git a/src/components/Settings/__stories__/Settings.stories.tsx b/src/components/Settings/__stories__/Settings.stories.tsx index 011fba82..ccea364c 100644 --- a/src/components/Settings/__stories__/Settings.stories.tsx +++ b/src/components/Settings/__stories__/Settings.stories.tsx @@ -6,6 +6,7 @@ import {Settings} from '..'; import {SettingsDemo} from './SettingsDemo'; import {SettingsMobileDemo} from './SettingsMobileDemo'; +import {SettingsOverflowDemo} from './SettingsOverflowDemo'; export default { title: 'components/Settings', @@ -23,6 +24,10 @@ export default { id: 'heading-order', // not relevant in stories enabled: false, }, + { + id: 'scrollable-region-focusable', // https://github.com/gravity-ui/uikit/issues/1549 + enabled: false, + }, ], }, }, @@ -34,3 +39,6 @@ export const Showcase = ShowcaseTemplate.bind({}); const ShowcaseMobileTemplate: StoryFn = () => ; export const ViewMobile = ShowcaseMobileTemplate.bind({}); + +const OverflowTemplate: StoryFn = () => ; +export const Overflow = OverflowTemplate.bind({}); diff --git a/src/components/Settings/__stories__/SettingsOverflowDemo.tsx b/src/components/Settings/__stories__/SettingsOverflowDemo.tsx new file mode 100644 index 00000000..3ddd3ec4 --- /dev/null +++ b/src/components/Settings/__stories__/SettingsOverflowDemo.tsx @@ -0,0 +1,59 @@ +import React from 'react'; + +import {Gear} from '@gravity-ui/icons'; +import {Switch} from '@gravity-ui/uikit'; + +import {Settings} from '../index'; + +export function SettingsOverflowDemo() { + const groups = Array.from({length: 5}, (_g, groupIndex) => ({ + id: `group-${groupIndex}`, + title: `Group ${groupIndex + 1}`, + pages: Array.from({length: 6}, (_p, pageIndex) => ({ + id: `group-${groupIndex}-page-${pageIndex}`, + title: `Page ${pageIndex + 1}`, + })), + })); + + const sections = Array.from({length: 8}, (_s, sectionIndex) => ({ + id: `section-${sectionIndex}`, + title: `Section ${sectionIndex + 1}`, + items: Array.from({length: 5}, (_i, itemIndex) => ({ + id: `section-${sectionIndex}-item-${itemIndex}`, + title: `Setting ${itemIndex + 1}`, + })), + })); + + return ( +
+ + {groups.map((group) => ( + + {group.pages.map((page) => ( + + {sections.map((section) => ( + + {section.items.map((item) => ( + + + + ))} + + ))} + + ))} + + ))} + +
+ ); +} diff --git a/src/components/Settings/__tests__/BurgerMenu.visual.test.tsx b/src/components/Settings/__tests__/BurgerMenu.visual.test.tsx index 139f9060..d4ab9e8a 100644 --- a/src/components/Settings/__tests__/BurgerMenu.visual.test.tsx +++ b/src/components/Settings/__tests__/BurgerMenu.visual.test.tsx @@ -16,4 +16,10 @@ test.describe('Settings', () => { await expectScreenshot(); }); + + test('render story: ', async ({mount, expectScreenshot}) => { + await mount(); + + await expectScreenshot(); + }); });