@@ -122,25 +122,39 @@ export class PruefiInputComponent implements ControlValueAccessor {
122
122
// Update the form control with just the pruefidentifikator
123
123
if ( pruefidentifikator ) {
124
124
this . control . setValue ( pruefidentifikator , { emitEvent : false } ) ;
125
+ // Emit changes immediately for dropdown selection
126
+ if ( this . onChange ) {
127
+ this . onChange ( pruefidentifikator ) ;
128
+ }
125
129
}
126
130
} else if ( digitOnlyPattern . test ( inputValue ) ) {
127
131
// Handle numeric input
128
132
if ( inputValue . length === 5 ) {
129
- // Exactly 5 digits
133
+ // Exactly 5 digits - trigger immediate load
130
134
pruefidentifikator = inputValue ;
135
+ // Update the form control with the 5 digits
136
+ this . control . setValue ( pruefidentifikator , { emitEvent : false } ) ;
137
+ // Emit changes immediately for 5-digit input
138
+ if ( this . onChange ) {
139
+ this . onChange ( pruefidentifikator ) ;
140
+ }
131
141
} else if ( inputValue . length > 5 ) {
132
142
// More than 5 digits - take first 5
133
143
pruefidentifikator = inputValue . slice ( 0 , 5 ) ;
134
144
// Update the form control with just the first 5 digits
135
145
this . control . setValue ( pruefidentifikator , { emitEvent : false } ) ;
146
+ // Emit changes immediately
147
+ if ( this . onChange ) {
148
+ this . onChange ( pruefidentifikator ) ;
149
+ }
136
150
}
137
151
// Less than 5 digits - treat as invalid (pruefidentifikator remains null)
138
152
}
139
153
// Any other format is considered invalid (pruefidentifikator remains null)
140
154
141
- // Emit changes
142
- if ( this . onChange ) {
143
- this . onChange ( pruefidentifikator ) ;
155
+ // Emit null for invalid input
156
+ if ( ! pruefidentifikator && this . onChange ) {
157
+ this . onChange ( null ) ;
144
158
}
145
159
}
146
160
}
0 commit comments