From 9d96e529c8ce9d5c32167ba8995ca328ee98c37c Mon Sep 17 00:00:00 2001 From: Baptiste Devessier Date: Wed, 8 Apr 2026 13:29:11 +0200 Subject: [PATCH] Fix last widget bottom bar inconsistencies (#19440) Widgets weren't sorted --- .../widgets/hooks/useIsCurrentWidgetLastOfTab.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/twenty-front/src/modules/page-layout/widgets/hooks/useIsCurrentWidgetLastOfTab.ts b/packages/twenty-front/src/modules/page-layout/widgets/hooks/useIsCurrentWidgetLastOfTab.ts index 7e41bc0e85..3d924f755c 100644 --- a/packages/twenty-front/src/modules/page-layout/widgets/hooks/useIsCurrentWidgetLastOfTab.ts +++ b/packages/twenty-front/src/modules/page-layout/widgets/hooks/useIsCurrentWidgetLastOfTab.ts @@ -2,9 +2,11 @@ import { useCurrentPageLayout } from '@/page-layout/hooks/useCurrentPageLayout'; import { useIsPageLayoutInEditMode } from '@/page-layout/hooks/useIsPageLayoutInEditMode'; import { buildWidgetVisibilityContext } from '@/page-layout/utils/buildWidgetVisibilityContext'; import { filterVisibleWidgets } from '@/page-layout/utils/filterVisibleWidgets'; +import { sortWidgetsByVerticalListPosition } from '@/page-layout/utils/sortWidgetsByVerticalListPosition'; import { useLayoutRenderingContext } from '@/ui/layout/contexts/LayoutRenderingContext'; import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile'; import { isDefined } from 'twenty-shared/utils'; +import { PageLayoutTabLayoutMode } from '~/generated-metadata/graphql'; export const useIsCurrentWidgetLastOfTab = (widgetId: string): boolean => { const { currentPageLayout } = useCurrentPageLayout(); @@ -24,13 +26,18 @@ export const useIsCurrentWidgetLastOfTab = (widgetId: string): boolean => { return false; } - const visibleWidgets = isPageLayoutInEditMode + const filteredWidgets = isPageLayoutInEditMode ? tab.widgets : filterVisibleWidgets({ widgets: tab.widgets, context: buildWidgetVisibilityContext({ isMobile, isInSidePanel }), }); + const visibleWidgets = + tab.layoutMode === PageLayoutTabLayoutMode.VERTICAL_LIST + ? sortWidgetsByVerticalListPosition(filteredWidgets) + : filteredWidgets; + if (visibleWidgets.length === 0) { return false; }