@@ -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,6 +268,7 @@ 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 ;
@@ -278,7 +279,12 @@ export class StringEditorViewModelBase extends Base {
278
279
super . dispose ( ) ;
279
280
this . detachFromUI ( ) ;
280
281
}
281
-
282
+ private addCreatorEvents ( ) {
283
+ this . creator ?. onLocaleChanded . add ( this . onLocaleChanged ) ;
284
+ }
285
+ private removeCreatorEvents ( ) {
286
+ this . creator ?. onLocaleChanded . remove ( this . onLocaleChanged ) ;
287
+ }
282
288
public activate = ( ) => {
283
289
const element = this . getEditorElement ( ) ;
284
290
if ( element && element . offsetParent != null ) {
@@ -290,10 +296,12 @@ export class StringEditorViewModelBase extends Base {
290
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