Skip to content

Commit beffa3b

Browse files
committed
Do not sync back in a two-way binding if target value is unchanged
This used to be the behavior in 3.7, but was changed in 3.8 when two-way converters were introduced. Technically it should not make a difference since it just prevents setting a property to a value it already has, but it seems to affect typing in TextInput widgets. Fix #84
1 parent 2228ee3 commit beffa3b

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/internals/TwoWayBinding.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import {Widget, WidgetCollection} from 'tabris';
2+
import {Conversion} from './Conversion';
13
import {CustomPropertyDescriptor} from './CustomPropertyDescriptor';
24
import {getJsxInfo} from './ExtendedJSX';
35
import {subscribe} from './subscribe';
4-
import {checkPropertyExists, TargetPath, WidgetInterface, Direction, BindingConverter} from './utils-databinding';
6+
import {BindingConverter, checkPropertyExists, Direction, TargetPath, WidgetInterface} from './utils-databinding';
57
import {injector} from '../api/Injector';
68
import {BindSuperConfig} from '../decorators/bind';
7-
import {Widget, WidgetCollection} from 'tabris';
8-
import {Conversion} from './Conversion';
99

1010
type LocalPath = [string, string?];
1111

@@ -106,7 +106,7 @@ export class TwoWayBinding {
106106
}
107107
if (this.initialized || this.targetHasPriority()) {
108108
this.setLocalValue(this.toLocalValue(targetValue));
109-
this.syncBackToTarget();
109+
this.syncBackToTarget(targetValue);
110110
}
111111
});
112112
}
@@ -128,10 +128,10 @@ export class TwoWayBinding {
128128
}
129129
}
130130

131-
private syncBackToTarget() {
131+
private syncBackToTarget(targetValue: unknown) {
132132
if (this.direction !== '<<' && this.hasValidSource()) {
133133
const finalValue = this.toTargetValue(this.getLocalValue());
134-
if (finalValue !== undefined) {
134+
if ((finalValue !== undefined) && (finalValue !== targetValue)) {
135135
this.setTargetValue(finalValue);
136136
}
137137
}

0 commit comments

Comments
 (0)