Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

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

Open
msqar opened this issue Aug 28, 2020 · 0 comments
Open

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

msqar opened this issue Aug 28, 2020 · 0 comments

Comments

@msqar
Copy link

msqar commented Aug 28, 2020

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant