@@ -397,12 +397,19 @@ export function guardedFields(
397397 return overflow ? null : out ;
398398}
399399
400+ // A real click on a checkbox, radio or select fires input, then change. Signal Forms
401+ // listens for input and the reactive and template-driven accessors listen for change.
402+ function dispatchPick ( element : Element ) : void {
403+ element . dispatchEvent ( new Event ( 'input' , { bubbles : true } ) ) ;
404+ element . dispatchEvent ( new Event ( 'change' , { bubbles : true } ) ) ;
405+ }
406+
400407function nativeWrite ( element : Element , value : unknown ) : boolean {
401408 if ( element instanceof HTMLInputElement ) {
402409 if ( element . type === 'file' ) return false ;
403410 if ( element . type === 'checkbox' ) {
404411 element . checked = ! ! value ;
405- element . dispatchEvent ( new Event ( 'change' , { bubbles : true } ) ) ;
412+ dispatchPick ( element ) ;
406413 return true ;
407414 }
408415 if ( element . type === 'radio' ) {
@@ -414,7 +421,7 @@ function nativeWrite(element: Element, value: unknown): boolean {
414421 ) as HTMLInputElement | undefined ;
415422 if ( ! target ) return false ;
416423 target . checked = true ;
417- target . dispatchEvent ( new Event ( 'change' , { bubbles : true } ) ) ;
424+ dispatchPick ( target ) ;
418425 return true ;
419426 }
420427 element . value = value == null ? '' : String ( value ) ;
@@ -467,7 +474,7 @@ function selectWrite(
467474 select . selectedIndex = index ;
468475 expected = options [ index ] . value ;
469476 }
470- select . dispatchEvent ( new Event ( 'change' , { bubbles : true } ) ) ;
477+ dispatchPick ( select ) ;
471478 return { expected } ;
472479}
473480
@@ -540,7 +547,14 @@ function writeValue(
540547 }
541548 if ( viaDom && nativeWrite ( element , value ) ) {
542549 if ( mode === 'user' ) element . dispatchEvent ( new Event ( 'blur' ) ) ;
543- return null ;
550+ const picked =
551+ element instanceof HTMLInputElement &&
552+ ( element . type === 'checkbox' || element . type === 'radio' ) ;
553+ if ( ! picked ) return null ;
554+ const expected = element . type === 'checkbox' ? ! ! value : value ;
555+ const deferred = found . kind !== 'signal' && read ( ( ) => node [ 'updateOn' ] , 'change' ) !== 'change' ;
556+ const stored = deferred ? node [ '_pendingValue' ] : rawValue ( found , node ) ;
557+ return sameOption ( stored , expected ) ? null : `holds ${ label ( stored ) } after the write` ;
544558 }
545559 if ( found . kind === 'template' && leaf ) {
546560 const dir = directivesOf ( node ) ;
0 commit comments