Skip to content

mat-datepicker with touchUI emits (closed) too soon? #17560

Closed
lingounet/testage
#29

Description

@robert-king

Reproduction

Steps to reproduce:
https://stackblitz.com/edit/components-issue-oa5rhf

<mat-form-field>
      <input
        matInput
        (focus)="picker.open()"
        required
        #input
        name="date"
        [matDatepicker]="picker"
        formControlName="serializedDate"
        placeholder="Working without blur">
      <mat-datepicker-toggle
        matSuffix
        [for]="picker">
      </mat-datepicker-toggle>
      <mat-datepicker
        [touchUi]="true"
        #picker>
      </mat-datepicker>
    </mat-form-field>

    <mat-form-field>
      <input
        matInput
        (focus)="picker2.open()"
        required
        #input2
        name="date"
        [matDatepicker]="picker2"
        formControlName="serializedDate"
        placeholder="Broken with blur">
      <mat-datepicker-toggle
        matSuffix
        [for]="picker2">
      </mat-datepicker-toggle>
      <mat-datepicker
        [touchUi]="true"
        (closed)="input2.blur()"
        #picker2>
      </mat-datepicker>
    </mat-form-field>

Expected Behavior

picker closes and then (close) emits and input.blur() is called

Actual Behavior

close emits and blur is called before the other (focus) is called?
The screen flashes in a loop and is frozen / unresponsive

Environment

see stackblitz - everything is the latest as of today AFAIK

Note: I do have a fix for this already, if i set a BIG timeout on the input.blur() of 150 MS, then it doesn't happen.

delayInputBlur(input: HTMLElement) {
    setTimeout(() => input.blur(), 150);
  }

Activity

  1. self-assigned this
    on Nov 17, 2019
  2. added
    P3
    on Nov 17, 2019
  3. added a commit that references this issue on Nov 17, 2019
    34a5997
  4. crisbeto commented on Nov 17, 2019

    @crisbeto
    Member

    Will be fixed by #17732. Until then your workaround with the timeout should work.

  5. added a commit that references this issue on Mar 6, 2020
    a91d84d
  6. added 2 commits that reference this issue on Apr 23, 2020
    bb30a3a
    d199500
  7. added a commit that references this issue on Apr 24, 2020
    324bf80
  8. angular-automatic-lock-bot commented on May 24, 2020

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  9. locked and limited conversation to collaborators on May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions