Fix relation-type and target-schema editing in the schema editor#951
Closed
JeroenDeDauw wants to merge 4 commits into
Closed
Fix relation-type and target-schema editing in the schema editor#951JeroenDeDauw wants to merge 4 commits into
JeroenDeDauw wants to merge 4 commits into
Conversation
Follows-up to #950 > Result of @JeroenDeDauw's review of #950: he requested the review, chose > the fix direction for the two findings, and directed this follow-up. > Context: the NeoWiki codebase, PR #950, and the sibling attribute editors. > <sub>Written by Claude Code, `Opus 4.8`</sub> Two follow-up fixes from the review of #950. Both stem from the same root: clearing a required relation attribute left the editor holding the previous value, so the field looked empty/blank while the stored value silently disagreed. - Relation type: `updateRelation` now emits the trimmed value even when empty, and the `relation` watcher no longer falls back to the property name. Clearing the field shows the required error and updates the model instead of keeping the stale value. The name fallback stays as the on-create default (initial value + `onMounted`), preserving the "derive-on-create only" behavior from #950. - Target schema: `SchemaLookup` now emits `select` on clear (dropping the `if ( schemaName )` guard that swallowed Codex's clear signal); the editor clears `targetSchema` accordingly and passes `null` to the lookup when unset. The other consumer, `SubjectCreatorDialog`, already ignores empty selections (`if ( !schemaName ) return`), so its behavior is unchanged. Required-field errors remain inline-only and still do not block Save — that schema-editor-wide gating was deferred in #950 and is unchanged here. These fixes make the displayed and validated state match what gets stored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The previous commit made SchemaLookup emit `select` on every cleared selection. But CdxLookup also deselects (emits update:selected null) while the user types to replace an existing value, so editing a set target schema round-tripped an empty value back and wiped the field mid-edit. Only emit the clear when the input is actually empty, matching SubjectLookup's onSubjectSelected guard. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The watch no longer falls back to the property name, so the name override implied a dependency the test does not exercise. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The target schema is a free-text CdxLookup, so typed text could drift from the actual selection (e.g. "Produc" while "Product" stays selected) with no feedback, and that stale value could be saved by changing another field. Reconcile on blur: keep a schema picked from the menu, clear when the field is emptied, otherwise revert unmatched text to the committed value. The field can now only hold an existing schema or nothing. Filtering still uses the server-side prefix search. Browser-verified on Schema:Company (revert, pick-to-replace, clear). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
JeroenDeDauw
force-pushed
the
fix/clear-relation-attributes
branch
from
June 27, 2026 14:57
16ce3fd to
26725fd
Compare
Member
Author
|
Folded into #953 for a single holistic review. #953 now targets |
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.
Follows-up to #950
Two editing fixes in the Schema editor's relation property, both stemming from fields that let the displayed value drift away from what gets stored.
Relation type (free-text edge label)
updateRelationnow emits the trimmed value even when empty, and therelationwatcher no longer falls back to the property name. Clearing the field shows the required error and updates the model instead of silently keeping the previous value. The name fallback remains the on-create default (initial value +onMounted), preserving the "derive-on-create only" behaviour from #950.Target schema (reference to an existing schema)
The field is a
CdxLookup, so typed text could drift from the actual selection (e.g.ProducwhileProductstayed selected) with no feedback — and that stale value could be saved by changing another field. It is now a constrained picker: it only ever holds an existing schema or nothing.Filtering still uses the existing server-side prefix search (
schema-namesAPI).SubjectCreatorDialog, which sharesSchemaLookup, already ignores empty selections, so its behaviour is unchanged.Required-field errors remain inline-only and still do not block Save — that schema-editor-wide gating was deferred in #950 and is unchanged here.
Known follow-up (not in this PR)
"Browse the full schema list before typing" is not included: the
schema-namesAPI is a prefix search capped at 10 results that rejects an empty query, so there is no cheap way to preload all names. Enabling browse needs a small new list-all-schema-names endpoint.Tests
RelationAttributesEditor: clearing emits an empty relation; a cleared field stays empty (no name snap-back); whitespace-only is trimmed/required;nullis passed to the lookup when no target schema is set.SchemaLookup: server search + result rendering; pick commits; unmatched text reverts on blur; empty + blur clears; an unset field is not cleared.Manual browser check (done; recorded here for re-verification)
On
Schema:Company→ Edit schema → select Main product:Owns→ stored trimmed.Product→Produc, click away → reverts toProduct.Off, pick Office from the dropdown → commits, no mid-type blanking.🤖 Generated with Claude Code