Skip to content

Commit b54c469

Browse files
JeroenDeDauwclaude
andcommitted
Don't blank the schema picker while typing a replacement
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>
1 parent c5eb0be commit b54c469

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

resources/ext.neowiki/src/components/common/SchemaLookup.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ async function onLookupInput( value: string ): Promise<void> {
7878
}
7979
8080
function onSchemaSelected( schemaName: string | null ): void {
81-
emit( 'select', schemaName ?? '' );
81+
if ( schemaName ) {
82+
emit( 'select', schemaName );
83+
} else if ( !inputText.value ) {
84+
emit( 'select', '' );
85+
}
8286
}
8387
8488
function focus(): void {

resources/ext.neowiki/tests/components/common/SchemaLookup.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,16 @@ describe( 'SchemaLookup', () => {
156156
expect( wrapper.emitted( 'select' )?.[ 0 ] ).toEqual( [ '' ] );
157157
} );
158158

159+
it( 'does not emit a clear while the user is typing a replacement', () => {
160+
const wrapper = mountComponent( { selected: 'Product' } );
161+
const lookup = wrapper.findComponent( CdxLookup );
162+
163+
lookup.vm.$emit( 'update:input-value', 'Off' );
164+
lookup.vm.$emit( 'update:selected', null );
165+
166+
expect( wrapper.emitted( 'select' ) ).toBeFalsy();
167+
} );
168+
159169
it( 'exposes focus method', () => {
160170
const CdxLookupStub = {
161171
template: '<div><input /></div>',

0 commit comments

Comments
 (0)