Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: global scroll without top alert #157

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/components/AsideHeader/AsideHeader.tsx
Original file line number Diff line number Diff line change
@@ -24,7 +24,10 @@ export const AsideHeader = React.forwardRef<HTMLDivElement, AsideHeaderProps>(
return (
<PageLayout compact={compact} className={className} topAlert={topAlert}>
<PageLayoutAside ref={ref} {...props} />
<PageLayout.Content renderContent={props.renderContent} />
<PageLayout.Content
renderContent={props.renderContent}
withTop={Boolean(topAlert)}
/>
</PageLayout>
);
},
Original file line number Diff line number Diff line change
@@ -31,14 +31,18 @@ const Layout = ({compact, reverse, className, children, topAlert}: PageLayoutPro
);
};

const ConnectedContent: React.FC<PropsWithChildren<Pick<ContentProps, 'renderContent'>>> = ({
children,
renderContent,
}) => {
const ConnectedContent: React.FC<
PropsWithChildren<Pick<ContentProps, 'renderContent' | 'withTop'>>
> = ({children, withTop, renderContent}) => {
const {size} = useAsideHeaderContext();

return (
<Content size={size} className={b('content')} renderContent={renderContent}>
<Content
withTop={withTop}
size={size}
className={b('content')}
renderContent={renderContent}
>
{children}
</Content>
);
9 changes: 7 additions & 2 deletions src/components/Content/Content.tsx
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ export interface ContentProps {
size: number;
className?: string;
cssSizeVariableName?: string;
withTop?: boolean;
renderContent?: RenderContentType;
}

@@ -26,15 +27,19 @@ export const Content: React.FC<ContentProps> = ({
size, // TODO: move to context when MobileHeader will support it
className,
cssSizeVariableName = '--gn-aside-header-size',
withTop,
renderContent,
children,
}) => {
const style: React.CSSProperties = {
[cssSizeVariableName]: `${size}px`,
maxHeight: 'calc(100vh - var(--gn-aside-top-panel-height))',
overflowY: 'auto',
};

if (withTop) {
style.maxHeight = 'calc(100vh - var(--gn-aside-top-panel-height))';
style.overflowY = 'auto';
}

return (
<div className={className} style={style}>
{typeof renderContent === 'function' ? (

Unchanged files with check annotations Beta

const openModalCount = data?.meta?.layers?.filter(
({type}) => type === 'modal',
).length;
callback(openModalCount !== 0);

Check warning on line 64 in src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx

GitHub Actions / Verify Files

Expected return with your callback function
}
});
};
multipleTooltip={multipleTooltip}
openModalSubscriber={openModalSubscriber}
topAlert={topAlert}
renderFooter={({compact, asideRef}) => (

Check warning on line 144 in src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx

GitHub Actions / Verify Files

'compact' is already declared in the upper scope
<React.Fragment>
<FooterItem
compact={compact}
window.removeEventListener('resize', updateTopSizeDebounce);
setAsideTopPanelHeight(0);
};
}, [topAlert, topHeight, topRef, updateTopSize]);

Check warning on line 56 in src/components/AsideHeader/useAsideHeaderTopPanel.tsx

GitHub Actions / Verify Files

React Hook React.useLayoutEffect has a missing dependency: 'setAsideTopPanelHeight'. Either include it or remove the dependency array
return {
topRef,
debounceFn(
() => {
const {
top = 0,

Check warning on line 42 in src/components/CompositeBar/HighlightedItem/HighlightedItem.tsx

GitHub Actions / Verify Files

'top' is already declared in the upper scope
left = 0,

Check warning on line 43 in src/components/CompositeBar/HighlightedItem/HighlightedItem.tsx

GitHub Actions / Verify Files

'left' is already declared in the upper scope
width = 0,

Check warning on line 44 in src/components/CompositeBar/HighlightedItem/HighlightedItem.tsx

GitHub Actions / Verify Files

'width' is already declared in the upper scope
height = 0,

Check warning on line 45 in src/components/CompositeBar/HighlightedItem/HighlightedItem.tsx

GitHub Actions / Verify Files

'height' is already declared in the upper scope
} = iconRef?.current?.getBoundingClientRect() || {};
setPosition({
handleResize();
window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);

Check warning on line 71 in src/components/CompositeBar/HighlightedItem/HighlightedItem.tsx

GitHub Actions / Verify Files

Arrow function expected no return value
}, [handleResize, isModalOpen]);
openModalSubscriber?.((open: boolean) => {
);
}}
onEvent={(itemName, eventName) => {
console.log(`[MobileHeader] onEvent ${itemName}, eventName ${eventName}`);

Check warning on line 218 in src/components/MobileHeader/__stories__/MobileHeaderShowcase.tsx

GitHub Actions / Verify Files

Unexpected console statement
}}
/>
</div>
const ref = React.useRef<HTMLDivElement>(null);
const tabItems = React.useMemo(() => {
const tabItems: TabsItemProps[] = [];

Check warning on line 19 in src/components/Settings/SettingsMenuMobile/SettingsMenuMobile.tsx

GitHub Actions / Verify Files

'tabItems' is already declared in the upper scope
items.forEach((firstLevelItem) => {
if ('groupTitle' in firstLevelItem) {