There is a timing issue between when the ng-select open callback is fired and the filterInput element is actually rendered. Your syntax is right, but filterInput is undefined when ng-select open emits. Refer to the following error from debug console in your provided stackblitz:
ERROR TypeError: Cannot read property 'nativeElement' of undefined
One approach to resolving this issue is to delay calling focus on the undefined element within the open callback. Below I've done just that by 1) capturing the filterInput ElementRef via @ViewChild, 2) refactor your current focus logic into a method within the component and added 250 ms delay, and 3) calling said method using the ng-select component open event emitter. I've provided an RxJS alternative to step 2 as well if preferred.
app.component.ts
// 1
@ViewChild('filterInput') filterInput: ElementRef;
// 2
setFilterFocus() {
setTimeout((() => { this.filterInput.nativeElement.focus() }).bind(this), 250)
}
app.component.html
<!-- 3 -->
<ng-select #api [items]="cars"
[virtualScroll]="true"
[loading]="loading"
bindLabel="brand"
bindValue="id"
(scroll)="onScroll($event)"
(scrollToEnd)="onScrollToEnd()"
[dropdownPosition]="'bottom'"
[searchable]="false"
[(ngModel)]="selectedCar2"
[searchFn]="customSearchFn"
(change)="onChange($event)"
(open)="setFilterFocus()">
Step 2 revisited - instead using RxJS
app.component.ts additional imports
import { of } from 'rxjs';
import { delay, tap } from 'rxjs/operators';
app.component.ts setFilterFocus RxJS style
setFilterFocus() {
of(null)
.pipe(
delay(250),
tap(() => this.filterInput.nativeElement.focus()))
.subscribe();
}