Skip to content

Improve editor to prevent layout breakage - #14

Merged
schmijos merged 25 commits into
developfrom
feature/25970-non-breaking-layout
Jul 20, 2026
Merged

Improve editor to prevent layout breakage#14
schmijos merged 25 commits into
developfrom
feature/25970-non-breaking-layout

Conversation

@timlandolt

Copy link
Copy Markdown
Collaborator

TICKET-25970

Now, opening a template will open a completely new page containing the content as an iframe as well as the editor.
This also allowed me to remove the error handling logic, as now the templates can still be edited with errors.
Opening the editor now works using a custom JS event that will open the whole new page if not opened yet. Otherwise, it will replace the editor using a turbo stream.

Other changes:

  • Separated JS and CSS into host for the host application and application for the engine views.
  • Added display: content; to make the custom elements less invasive (can be seen with the newly added "grid" in the dummy app)

@timlandolt timlandolt self-assigned this Jun 23, 2026
@timlandolt
timlandolt marked this pull request as ready for review June 23, 2026 14:42
@timlandolt
timlandolt requested a review from schmijos June 23, 2026 14:42

@schmijos schmijos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The system tests are still missing? How do you prove to me that "it still all works"?

params.append("template[render_path][]", p),
);

return `/ferbe/template/edit?${params.toString()}`;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These are still static paths.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I am aware. I plan to implement this together with the changes to the generator in TICKET-25969 later

@timlandolt

Copy link
Copy Markdown
Collaborator Author

The system tests are still missing? How do you prove to me that "it still all works"?
@schmijos

I wanted to wait for your approval of the new approach first. Also, there's a separate Ticket (TICKET-25972). Should I add them In a separate PR first? or in this one? or add them later?

@schmijos

Copy link
Copy Markdown
Member

Let's do them tests separately.

@schmijos schmijos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, I happy with that approach! Some minor improvement suggestions, otherwise good to merge.

params.append("template[path]", template.filePath);
template.renderPath.forEach((p) =>
params.append("template[render_path][]", p),
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What about a more declarative approach?

const params = new URLSearchParams([
  ["url", url],
  ["template[path]", template.filePath],
  ...template.renderPath.map((p) => ["template[render_path][]", p] as const),
]);

.then((r) => r.text())
.then((html) => {
Turbo.renderStreamMessage(html);
window.history.pushState({}, "", editorUrl(template));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are you fiddling with the history here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

So the history/url reflects the current editor state.
But it is buggy and when navigating the render path it also doesn't get updated.
I will remove it.

.then((r) => r.text())
.then((html) => Turbo.renderStreamMessage(html))
.catch((err) => console.error("Failed to open editor:", err));
window.top.dispatchEvent(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's an interesting idea. I wouldn't have thought of that but used postMessage instead. But you're totally right. Cross-origin communication is not needed.

Comment on lines +4 to +8
params.append("url", template.url);
params.append("template[path]", template.filePath);
template.renderPath.forEach((p) =>
params.append("template[render_path][]", p),
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Second time occurrence of this pattern.

@timlandolt
timlandolt requested a review from schmijos July 17, 2026 09:43

@schmijos schmijos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice! That sparks joy!

@schmijos
schmijos merged commit 93e9d6a into develop Jul 20, 2026
1 check passed
@schmijos
schmijos deleted the feature/25970-non-breaking-layout branch July 20, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants