Lock focus on <ion-input>, prevent blur

Hello,

I am having difficulty writing a Directive (or whatever it should be) that will prevent an from losing focus if the user taps elsewhere. I’m trying to revise my old Directive that was previously working. The event that is being received in my hook, onIonBlur is a “CustomEvent”. Not sure how to get this working.

Thanks.

– example use
<ion-input type=“text” [focusIf]=“true” [(ngModel)]=“theFieldValue” … />

@Directive({
    selector: '[focusIf]'
})
export class FocusIfDirective implements OnChanges {

    ngOnChanges(changes: SimpleChanges): void {
        if (this.doFocus) {
            this.focus();
        }
    }

    @Input('focusIf') doFocus: boolean;

    constructor(@Inject(ElementRef) private element: ElementRef, private renderer: Renderer2) {
    }

    @HostListener('ionBlur', ['$event'])
    public onIonBlur(inEvent) {
        // don't allow blur. refocus
        if (this.doFocus) {
            this.focus();
        }
    }

    private focus() {
        // is it even necessary to refocus in a timer?
        let focusTimer = Observable.timer(250, 0)
            .subscribe(() => {
                    this.element.nativeElement.focus();
                    focusTimer.unsubscribe();
                }
            );
    }
}