MishkaCmsCore. Runtime. Resources. Validations. StatefulIds
(Mishka CMS Core v0.0.1)
Copy Markdown
View Source
Refuses a page that places two live components under one id.
Why this is a rule and not a warning
Phoenix.LiveView.Diff raises on it:
found duplicate ID "…" for component … when rendering templateinside whichever LiveView renders the page, where nothing contains it. An advisory would be the wrong shape for something that is certain to take the page down rather than merely likely to look wrong.
Why the editor's own minting is not enough
EditorSession.with_id/4 mints one per drop and PageBuilder.Ids.dedupe/2 renames the arrivals
that collided — but dedupe/2 is deliberately given the nodes that ARRIVED, and answers nothing
when a whole document arrives at once. That is exactly what the source window does: an author
pastes markup, and a copy-paste of a component tag inside it carries the same id twice with
nothing to call an arrival. A draft restore and a seeded template have the same shape.
So this is asked of the stored markup, at the action boundary, where every writer passes.
Only live components, and only literal ids
A function component with a duplicate id is a bad idea and not a crash, and the editor already
renames those. id={@row.id} is the author binding the id to their data and two of them are not a
collision — the same distinction PageBuilder.Ids draws.