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 Filtered index view infinite re-render #5286

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
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
13 changes: 2 additions & 11 deletions packages/twenty-front/src/modules/views/components/ViewBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ import { ObjectFilterDropdownButton } from '@/object-record/object-filter-dropdo
import { FiltersHotkeyScope } from '@/object-record/object-filter-dropdown/types/FiltersHotkeyScope';
import { ObjectSortDropdownButton } from '@/object-record/object-sort-dropdown/components/ObjectSortDropdownButton';
import { TopBar } from '@/ui/layout/top-bar/TopBar';
import { PageTitle } from '@/ui/utilities/page-title/PageTitle';
import { QueryParamsFiltersEffect } from '@/views/components/QueryParamsFiltersEffect';
import { QueryParamsViewIdEffect } from '@/views/components/QueryParamsViewIdEffect';
import { ViewBarEffect } from '@/views/components/ViewBarEffect';
import { ViewBarFilterEffect } from '@/views/components/ViewBarFilterEffect';
import { ViewBarPageTitle } from '@/views/components/ViewBarPageTitle';
import { ViewBarSortEffect } from '@/views/components/ViewBarSortEffect';
import { useGetCurrentView } from '@/views/hooks/useGetCurrentView';
import { ViewScope } from '@/views/scopes/ViewScope';
import { GraphQLView } from '@/views/types/GraphQLView';
import { ViewPickerDropdown } from '@/views/view-picker/components/ViewPickerDropdown';
import { capitalize } from '~/utils/string/capitalize';

import { ViewsHotkeyScope } from '../types/ViewsHotkeyScope';

Expand All @@ -37,20 +35,13 @@ export const ViewBar = ({
}: ViewBarProps) => {
const { objectNamePlural } = useParams();

const { currentViewWithCombinedFiltersAndSorts: currentView } =
useGetCurrentView(viewBarId);

const filterDropdownId = 'view-filter';
const sortDropdownId = 'view-sort';

if (!objectNamePlural) {
return;
}

const pageTitle = currentView?.name
? `${currentView?.name} - ${capitalize(objectNamePlural)}`
: capitalize(objectNamePlural);

return (
<ViewScope
viewScopeId={viewBarId}
Expand All @@ -62,7 +53,7 @@ export const ViewBar = ({
<QueryParamsFiltersEffect />
<QueryParamsViewIdEffect />

<PageTitle title={pageTitle} />
<ViewBarPageTitle viewBarId={viewBarId} />
<TopBar
className={className}
leftComponent={
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useParams } from 'react-router-dom';

import { PageTitle } from '@/ui/utilities/page-title/PageTitle';
import { useGetCurrentView } from '@/views/hooks/useGetCurrentView';
import { capitalize } from '~/utils/string/capitalize';

export type ViewBarPageTitleProps = {
viewBarId: string;
};

export const ViewBarPageTitle = ({ viewBarId }: ViewBarPageTitleProps) => {
const { objectNamePlural } = useParams();

const { currentViewWithCombinedFiltersAndSorts: currentView } =
useGetCurrentView(viewBarId);

if (!objectNamePlural) {
return;
}

const pageTitle = currentView?.name
? `${currentView?.name} - ${capitalize(objectNamePlural)}`
: capitalize(objectNamePlural);

return <PageTitle title={pageTitle} />;
};
Loading