fix: keep responsive layout editors stable
This commit is contained in:
1 parent
1b843817a4
commit
71ffa5d1be
1 file changed
+4
-6
@@ -111,9 +111,6 @@ export const LayoutSettingsContent = ({ board, form, isSaving, saveSettingsAsync
|
|||||||
|
|
||||||
const nextBreakpoint = getNextCustomBreakpoint(form.values.layouts);
|
const nextBreakpoint = getNextCustomBreakpoint(form.values.layouts);
|
||||||
const baseLayout = form.values.layouts.find((layout) => layout.role === "base");
|
const baseLayout = form.values.layouts.find((layout) => layout.role === "base");
|
||||||
const sortedLayouts = form.values.layouts
|
|
||||||
.map((layout, index) => ({ layout, index }))
|
|
||||||
.toSorted((entryA, entryB) => entryA.layout.breakpoint - entryB.layout.breakpoint);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SectionCard title={tBoard("setting.section.layout.title")}>
|
<SectionCard title={tBoard("setting.section.layout.title")}>
|
||||||
@@ -129,7 +126,7 @@ export const LayoutSettingsContent = ({ board, form, isSaving, saveSettingsAsync
|
|||||||
disabled={nextBreakpoint === null || !baseLayout}
|
disabled={nextBreakpoint === null || !baseLayout}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (nextBreakpoint === null || !baseLayout) return;
|
if (nextBreakpoint === null || !baseLayout) return;
|
||||||
form.setFieldValue("layouts", [
|
const layouts = [
|
||||||
...form.values.layouts,
|
...form.values.layouts,
|
||||||
{
|
{
|
||||||
id: createId(),
|
id: createId(),
|
||||||
@@ -140,14 +137,15 @@ export const LayoutSettingsContent = ({ board, form, isSaving, saveSettingsAsync
|
|||||||
breakpoint: nextBreakpoint,
|
breakpoint: nextBreakpoint,
|
||||||
role: "custom",
|
role: "custom",
|
||||||
},
|
},
|
||||||
]);
|
].toSorted((layoutA, layoutB) => layoutA.breakpoint - layoutB.breakpoint);
|
||||||
|
form.setFieldValue("layouts", layouts);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{tBoard("setting.section.layout.responsive.action.add")}
|
{tBoard("setting.section.layout.responsive.action.add")}
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
{sortedLayouts.map(({ layout, index }) => {
|
{form.values.layouts.map((layout, index) => {
|
||||||
const persistedLayout = board.layouts.find((candidate) => candidate.id === layout.id);
|
const persistedLayout = board.layouts.find((candidate) => candidate.id === layout.id);
|
||||||
const sourceLayout = persistedLayout ?? board.layouts.find((candidate) => candidate.role === "base");
|
const sourceLayout = persistedLayout ?? board.layouts.find((candidate) => candidate.role === "base");
|
||||||
const customBreakpoints = form.values.layouts
|
const customBreakpoints = form.values.layouts
|
||||||
|
|||||||
Reference in new issue
Block a user