#Persist parent layout while navigating between parent and nested layouts

1 messages · Page 1 of 1 (latest)

unkempt terrace
#

Is there a way to persist the shared parent layout if you navigate between components that simply use a parent layout:

<script>
import AppLayout from '@/Layouts/AppLayout';

export default {
    layout: AppLayout
};
</script>

And then navigate to another page which has the same parent layout, but a child layout nested in the parent? Right now I'm seeing the parent gets re-mounted when switching back and forth with just the parent, or the child & parent nested.

<script>
import AppLayout from '@/Layouts/AppLayout';
import ProjectLayout from '@/Layouts/ProjectLayout';

export default {
    layout: [ProjectLayout, AppLayout]
};
</script>

The layouts persist when switching between parent only, or nested pages. But switching between parent only and nested will cause the parent to remount.

Thanks in advance 🙂

exotic hazel
#

No.

#

There is nothing Inertia can do to save the state of the sub component.

#

For context, you are fighting Vue here. It's going to unmount AppLayout, the create/mount ProjectLayout, then do the same with AppLayout inside that.

#

It has zero context that it can see to even start thinking it can reuse original AppLayout for the second one.