Refacto scroll + Aggregate queries for view groups (#9089)
Closes https://github.com/twentyhq/private-issues/issues/217. Refactoring scroll not to cause table-wide re-render when opening a dropdown (triggering a scroll lock) in the table.
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { ScrollWrapper } from '@/ui/utilities/scroll/components/ScrollWrapper';
|
||||
import styled from '@emotion/styled';
|
||||
import { useId } from 'react';
|
||||
|
||||
const StyledDropdownMenuItemsExternalContainer = styled.div<{
|
||||
hasMaxHeight?: boolean;
|
||||
@ -44,13 +45,18 @@ export const DropdownMenuItemsContainer = ({
|
||||
className?: string;
|
||||
withoutScrollWrapper?: boolean;
|
||||
}) => {
|
||||
const id = useId();
|
||||
|
||||
return withoutScrollWrapper === true ? (
|
||||
<StyledDropdownMenuItemsExternalContainer
|
||||
hasMaxHeight={hasMaxHeight}
|
||||
className={className}
|
||||
>
|
||||
{hasMaxHeight ? (
|
||||
<StyledScrollWrapper contextProviderName="dropdownMenuItemsContainer">
|
||||
<StyledScrollWrapper
|
||||
contextProviderName="dropdownMenuItemsContainer"
|
||||
componentInstanceId={`scroll-wrapper-dropdown-menu-${id}`}
|
||||
>
|
||||
<StyledDropdownMenuItemsInternalContainer>
|
||||
{children}
|
||||
</StyledDropdownMenuItemsInternalContainer>
|
||||
@ -62,7 +68,10 @@ export const DropdownMenuItemsContainer = ({
|
||||
)}
|
||||
</StyledDropdownMenuItemsExternalContainer>
|
||||
) : (
|
||||
<ScrollWrapper contextProviderName="dropdownMenuItemsContainer">
|
||||
<ScrollWrapper
|
||||
contextProviderName="dropdownMenuItemsContainer"
|
||||
componentInstanceId={`scroll-wrapper-dropdown-menu-${id}`}
|
||||
>
|
||||
<StyledDropdownMenuItemsExternalContainer
|
||||
hasMaxHeight={hasMaxHeight}
|
||||
className={className}
|
||||
|
||||
@ -31,7 +31,10 @@ export const ShowPageContainer = ({ children }: ShowPageContainerProps) => {
|
||||
const isMobile = useIsMobile();
|
||||
return isMobile ? (
|
||||
<StyledOuterContainer>
|
||||
<StyledScrollWrapper contextProviderName="showPageContainer">
|
||||
<StyledScrollWrapper
|
||||
contextProviderName="showPageContainer"
|
||||
componentInstanceId={'scroll-wrapper-show-page-container'}
|
||||
>
|
||||
<StyledInnerContainer>{children}</StyledInnerContainer>
|
||||
</StyledScrollWrapper>
|
||||
</StyledOuterContainer>
|
||||
|
||||
@ -23,7 +23,10 @@ export const ShowPageActivityContainer = ({
|
||||
);
|
||||
|
||||
return !isNewViewableRecordLoading ? (
|
||||
<ScrollWrapper contextProviderName="showPageActivityContainer">
|
||||
<ScrollWrapper
|
||||
contextProviderName="showPageActivityContainer"
|
||||
componentInstanceId={`scroll-wrapper-tab-list-${targetableObject.id}`}
|
||||
>
|
||||
<StyledShowPageActivityContainer>
|
||||
<RichTextEditor
|
||||
activityId={targetableObject.id}
|
||||
|
||||
@ -46,7 +46,10 @@ export const ShowPageLeftContainer = ({
|
||||
{children}
|
||||
</StyledInnerContainer>
|
||||
) : (
|
||||
<ScrollWrapper contextProviderName="showPageLeftContainer">
|
||||
<ScrollWrapper
|
||||
contextProviderName="showPageLeftContainer"
|
||||
componentInstanceId={`scroll-wrapper-show-page-left-container`}
|
||||
>
|
||||
<StyledIntermediateContainer>
|
||||
<StyledInnerContainer isMobile={isMobile}>
|
||||
{children}
|
||||
|
||||
@ -7,8 +7,9 @@ import { TabListScope } from '@/ui/layout/tab/scopes/TabListScope';
|
||||
|
||||
import { TabListFromUrlOptionalEffect } from '@/ui/layout/tab/components/TabListFromUrlOptionalEffect';
|
||||
import { LayoutCard } from '@/ui/layout/tab/types/LayoutCard';
|
||||
import { Tab } from './Tab';
|
||||
import { ScrollWrapper } from '@/ui/utilities/scroll/components/ScrollWrapper';
|
||||
import { useEffect } from 'react';
|
||||
import { Tab } from './Tab';
|
||||
|
||||
export type SingleTabProps = {
|
||||
title: string;
|
||||
@ -70,26 +71,32 @@ export const TabList = ({
|
||||
componentInstanceId={tabListInstanceId}
|
||||
tabListIds={tabs.map((tab) => tab.id)}
|
||||
/>
|
||||
<StyledTabsContainer>
|
||||
{visibleTabs.map((tab) => (
|
||||
<Tab
|
||||
id={tab.id}
|
||||
key={tab.id}
|
||||
title={tab.title}
|
||||
Icon={tab.Icon}
|
||||
logo={tab.logo}
|
||||
active={tab.id === activeTabId}
|
||||
disabled={tab.disabled ?? loading}
|
||||
pill={tab.pill}
|
||||
to={behaveAsLinks ? `#${tab.id}` : undefined}
|
||||
onClick={() => {
|
||||
if (!behaveAsLinks) {
|
||||
setActiveTabId(tab.id);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</StyledTabsContainer>
|
||||
<ScrollWrapper
|
||||
defaultEnableYScroll={false}
|
||||
contextProviderName="tabList"
|
||||
componentInstanceId={`scroll-wrapper-tab-list-${tabListInstanceId}`}
|
||||
>
|
||||
<StyledTabsContainer>
|
||||
{visibleTabs.map((tab) => (
|
||||
<Tab
|
||||
id={tab.id}
|
||||
key={tab.id}
|
||||
title={tab.title}
|
||||
Icon={tab.Icon}
|
||||
logo={tab.logo}
|
||||
active={tab.id === activeTabId}
|
||||
disabled={tab.disabled ?? loading}
|
||||
pill={tab.pill}
|
||||
to={behaveAsLinks ? `#${tab.id}` : undefined}
|
||||
onClick={() => {
|
||||
if (!behaveAsLinks) {
|
||||
setActiveTabId(tab.id);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</StyledTabsContainer>
|
||||
</ScrollWrapper>
|
||||
</TabListScope>
|
||||
</StyledContainer>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user