@@ -256,7 +256,7 @@ export class StringEditorViewModelBase extends Base {
256
256
super ( ) ;
257
257
this . locString = locString ;
258
258
this . checkMarkdownToTextConversion ( this . locString . owner , this . locString . name ) ;
259
- this . creator ?. onLocaleChanded . add ( this . onLocaleChanged ) ;
259
+ this . addCreatorEvents ( ) ;
260
260
}
261
261
private onLocaleChanged = ( ) => {
262
262
this . resetPropertyValue ( "placeholderValue" ) ;
@@ -268,13 +268,13 @@ export class StringEditorViewModelBase extends Base {
268
268
}
269
269
270
270
public detachFromUI ( ) {
271
+ this . removeCreatorEvents ( ) ;
271
272
this . connector ?. onDoActivate . remove ( this . activate ) ;
272
273
this . getEditorElement = undefined ;
273
274
this . blurEditor = undefined ;
274
275
}
275
276
276
277
public dispose ( ) : void {
277
- this . creator ?. onLocaleChanded . remove ( this . onLocaleChanged ) ;
278
278
super . dispose ( ) ;
279
279
this . detachFromUI ( ) ;
280
280
}
@@ -288,12 +288,20 @@ export class StringEditorViewModelBase extends Base {
288
288
}
289
289
return false ;
290
290
}
291
+ private addCreatorEvents ( ) {
292
+ this . creator ?. onLocaleChanded . add ( this . onLocaleChanged ) ;
293
+ }
294
+ private removeCreatorEvents ( ) {
295
+ this . creator ?. onLocaleChanded . remove ( this . onLocaleChanged ) ;
296
+ }
291
297
292
298
public setLocString ( locString : LocalizableString ) {
299
+ this . removeCreatorEvents ( ) ;
293
300
this . connector ?. onDoActivate . remove ( this . activate ) ;
294
301
this . locString = locString ;
295
302
this . connector = StringEditorConnector . get ( locString ) ;
296
303
this . connector . onDoActivate . add ( this . activate ) ;
304
+ this . addCreatorEvents ( ) ;
297
305
}
298
306
public checkConstraints ( event : any ) {
299
307
if ( ! this . compostionInProgress && this . maxLength > 0 && event . keyCode >= 32 ) {
0 commit comments