Skip to content

Fix issue with newly created template under an existing one #19669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ export class UmbTemplateWorkspaceContext
}

override async load(unique: string) {
// Reset state before load to ensure we don't short-circuit the load method.
// Without this on editing a newly created template we won't get the created data,
// rather the initial scaffold.
super.resetState();
Copy link
Member

@nielslyngsoe nielslyngsoe Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem right, here a few notes from the investigation for who ever gets to look into this next.

The data scaffolded via the Creation flow does not seem to set the masterTemplate of the data.
Which results in the Master Template being gone when the line below (74):
this.setMasterTemplate(response.data.masterTemplate?.unique ?? null); gets executed.

This should not be resolved by loading the template from the server again, but instead, we should make sure the Master Template logic sets the masterTemplate in the 'current' data, so our data is correct.

Currently, we do not experience this data problem because the Master Template is being displayed from a UI state and not bound to the data of the template.

So instead we should update the data as part of this.setMasterTemplate.

Something like this:

this._data.updateCurrent({ masterTemplate: { unique: ... } });

I will as well add that we should consider if the whole State for Master Template could be omitted in favor of an Observable part for that specific part of the data. I have not had the time at hand to investigate this closer, but it seems that could make everything a lot simpler.

const response = await super.load(unique);
if (response.data) {
this.setMasterTemplate(response.data.masterTemplate?.unique ?? null);
Expand Down
Loading