fix(builder): evitar caos de layout cuando free-drag no tiene posiciones validas
This commit is contained in:
@@ -2940,6 +2940,15 @@ const state = {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
function hasMeaningfulFreeDragPositions(blocks){
|
||||
const nonMenu = (Array.isArray(blocks) ? blocks : []).filter((b)=>b && b.type !== "menu");
|
||||
if (!nonMenu.length) return false;
|
||||
const positioned = nonMenu.filter((b)=>{
|
||||
const p = b && b.pos;
|
||||
return p && Number.isFinite(Number(p.x)) && Number.isFinite(Number(p.y));
|
||||
});
|
||||
return positioned.length >= Math.max(2, Math.ceil(nonMenu.length * 0.5));
|
||||
}
|
||||
async function saveContent(){
|
||||
if (isSaving) return;
|
||||
isSaving = true;
|
||||
@@ -3013,8 +3022,14 @@ const state = {
|
||||
state.blocks.forEach(b=>{ if (!b.page) b.page = "home"; });
|
||||
state.settings.free_drag = false;
|
||||
} else {
|
||||
// Restaurante usa posicionamiento libre para colocar bloques donde el usuario quiera.
|
||||
state.settings.free_drag = initialRubro === "restaurante";
|
||||
const savedFreeDrag = typeof state.settings.free_drag === "boolean" ? state.settings.free_drag : false;
|
||||
if (!savedFreeDrag){
|
||||
state.settings.free_drag = false;
|
||||
} else {
|
||||
// Compatibilidad: si un sitio viene marcado como free_drag pero no tiene posiciones
|
||||
// reales, volvemos a flujo normal para evitar superposicion de bloques.
|
||||
state.settings.free_drag = hasMeaningfulFreeDragPositions(state.blocks);
|
||||
}
|
||||
}
|
||||
selectedBlockId = null;
|
||||
wireSidebar();
|
||||
|
||||
Reference in New Issue
Block a user