Skip to content

Commit 3c6ac7d

Browse files
committed
fix(select): Fixed select not working due to strict null checks
1 parent 856d6e0 commit 3c6ac7d

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

components/search/search.service.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,20 @@ export class SearchService<T> {
151151
return;
152152
}
153153

154-
if (this.optionsField) {
155154
// Convert the query string to a RegExp.
156-
const regex = this.toRegex(this._query);
155+
const regex = this.toRegex(this._query);
157156

158-
if (regex instanceof RegExp) {
157+
if (regex instanceof RegExp) {
159158
// Only update the results if the query was valid regex.
160159
// This avoids the results suddenly becoming empty if an invalid regex string is inputted.
161-
this.updateResults(this._options
162-
// Filter on the options with a string match on the field we are testing.
163-
.filter(o => readValue<T, string>(o, this._optionsField)
164-
.toString()
165-
.match(regex)));
166-
}
167-
168-
return callback();
160+
this.updateResults(this._options
161+
// Filter on the options with a string match on the field we are testing.
162+
.filter(o => readValue<T, string>(o, this._optionsField)
163+
.toString()
164+
.match(regex)));
169165
}
166+
167+
return callback();
170168
}
171169

172170
// Updates & caches the new set of results.

components/select/select.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export type SingleItemLookup<T, U> = (query:string, initial?:U) => Promise<T>;
2222
<!-- Selected item -->
2323
<div class="text" [class.filtered]="!!query || !selectedOption">
2424
<span #optionTemplateSibling></span>
25-
<span *ngIf="!optionTemplate">{{ labelGetter(selectedOption) }}</span>
25+
<span *ngIf="!optionTemplate && selectedOption">{{ labelGetter(selectedOption) }}</span>
2626
</div>
2727
<!-- Select dropdown menu -->
2828
<div class="menu"

0 commit comments

Comments
 (0)