trimox / angular-mdc-web

Angular wrapper for Material Design (Web) Components
https://trimox.github.io/angular-mdc-web
MIT License
519 stars 87 forks source link

mdc-text-field blur is triggering focus every time #2280

Open msqar opened 3 years ago

msqar commented 3 years ago

Describe the bug After debugging the MDC code, noticed that textfield.js has some logic into the onBlur which intentionally triggers focus. Why would this be like that? In my case, I have onFocus functionality that I need to execute, and it's causing me problems.

Here's the snippet:

    onBlur() {
        this._onTouched();
        this._foundation.deactivateFocus();
        this.blur.emit(this.value);
        this._onFocus.emit(false); // <-- this line
    }

Here's my piece of code:

                    <mdc-text-field
                        outlined
                        class="someClass"
                        name="someName"
                        id="someId"
                        (focus)="clearInput(param1, param2)"
                        required
                        >
                    </mdc-text-field>

Expected behavior Clicking out of input should not trigger on focus. Now, whenever I click out, it's clearing my input. This behaviour i need it to happen only when i intentionally focus in the input by clicking in it, not out.

What Angular MDC version are you using? "@angular-mdc/web": "^5.1.1",

What OS are you using?: macOS

What browser(s) is this bug affecting?: Chrome

Additional context Add any other context about the problem here.