Skip to content

Commit c4d4823

Browse files
committed
SVYX-926 TiNG Typehead issue when NULL has a displayValue
introduce a NULL_VALUE that is set to the model when a null is in the dataprovider. then the input formatter sets that back to a reall null (from that NULL_VALUE) and just searches the valuelist (removing the == null check there)
1 parent 0e0e780 commit c4d4823

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

projects/bootstrapcomponents/src/typeahead/typeahead.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[svyStartEdit]="'dataProviderID'"
66
[hostComponent]="this"
77
[svyTabFix]="this"
8-
[(ngModel)]="dataProviderID"
8+
[ngModel]="dataProvider"
99
(change)="pushUpdate()"
1010
(selectItem)="valueChanged($event)"
1111
[sabloTabseq]="tabSeq"

projects/bootstrapcomponents/src/typeahead/typeahead.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { ServoyBootstrapBasefield } from '../bts_basefield';
1313
})
1414
export class ServoyBootstrapTypeahead extends ServoyBootstrapBasefield<HTMLInputElement> implements IPopupSupportComponent{
1515

16+
private readonly NULL_VALUE = 'TS_NULL_VALUE';
17+
1618
@ViewChild('instance') instance: NgbTypeahead;
1719

1820
@Input() showAs: string;
@@ -63,6 +65,11 @@ export class ServoyBootstrapTypeahead extends ServoyBootstrapBasefield<HTMLInput
6365
});
6466
}
6567

68+
get dataProvider() {
69+
if (this.dataProviderID === null) return this.NULL_VALUE;
70+
return this.dataProviderID;
71+
}
72+
6673
svyOnChanges(changes: SimpleChanges) {
6774
super.svyOnChanges(changes);
6875
if (changes.enabled || changes.findmode) {
@@ -158,8 +165,10 @@ export class ServoyBootstrapTypeahead extends ServoyBootstrapBasefield<HTMLInput
158165
};
159166

160167
inputFormatter = (result: any) => {
161-
if (result === null) return '';
162-
if (result.displayValue !== undefined) result = result.displayValue;
168+
if (result === this.NULL_VALUE) {
169+
result = null;
170+
}
171+
if (result?.displayValue !== undefined) result = result.displayValue;
163172
else if (this.valuelistID?.hasRealValues()) {
164173
// on purpose test with == so that "2" equals to 2
165174
const value = this.valuelistID.find((item) => {

0 commit comments

Comments
 (0)