fix(ui): keep an unnamed class out of the schema removal preview, one at a time - #782
Merged
Conversation
… at a time Deleting a class previews the remaining draft through POST /schema/preview, whose body is publish-shaped and refuses a blank name. With two unnamed classes the leftover one turned every delete into a 422 alert. A class with no name was never published and cannot carry annotations, so removing it is a local edit; removing a named class previews the named classes only. Add class now adds nothing while a class is still unnamed: it selects that class and says so, the remedy Save already uses for the same blank.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Deleting a class in the Schema tab previews the remaining draft through
POST /schema/preview. That body is publish-shaped, and the kernel refuses a blank class name, so with two or more unnamed classes every delete surfaced as "Could not preview this change · The request payload is not processable". The kernel and the wire are right and untouched; the editor was sending an unpublishable document to a publish-shaped endpoint.SchemaEditor.tsx: a class with no name was never published and cannot carry annotations, so removing it is a local edit with no request; removing a named class previews the named classes only.boxand the picker never lets the last shape be unticked.docs/content/ui.md: the schema-editor section states the rule.Found, not fixed
Nothing.
Test plan
vitestonscreens.test.tsx+schemaDraft.test.tsx: 129 pass. Three new cases — blank removal sends no preview, named removal sends only the named classes, second Add is refused until the first is named — each proven to fail with the fix stashed.pnpm --filter @visionset/ui-core lint