Instant widget placeholder placement on drag end (#15496)

closes -
https://discord.com/channels/1130383047699738754/1430596561137700957

fixed a bug - where on chart type change in side panel -- wont update
the widgets minimum size

---------

Co-authored-by: Raphaël Bosi <71827178+bosiraphael@users.noreply.github.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
nitin
2025-11-03 22:38:13 +05:30
committed by GitHub
parent 9c695cfed5
commit 902eb2c5d2
21 changed files with 1545 additions and 55 deletions
@@ -0,0 +1,35 @@
import { PENDING_WIDGET_PLACEHOLDER_LAYOUT_KEY } from '@/page-layout/constants/PendingWidgetPlaceholderLayoutKey';
import { type GridLayoutItem } from '@/page-layout/types/GridLayoutItem';
import { isDefined } from 'twenty-shared/utils';
import { type PageLayoutWidget } from '~/generated/graphql';
export const prepareGridLayoutItemsWithPlaceholders = (
widgets: PageLayoutWidget[] | undefined,
shouldIncludePendingPlaceholder: boolean,
): GridLayoutItem[] => {
const hasWidgets = isDefined(widgets) && widgets.length > 0;
if (!hasWidgets) {
return [
{
id: 'empty-placeholder',
type: 'placeholder' as const,
},
];
}
const gridLayoutItems: GridLayoutItem[] = widgets.map((widget) => ({
id: widget.id,
type: 'widget' as const,
widget,
}));
if (shouldIncludePendingPlaceholder) {
gridLayoutItems.push({
id: PENDING_WIDGET_PLACEHOLDER_LAYOUT_KEY,
type: 'placeholder' as const,
});
}
return gridLayoutItems;
};