Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mat-Form-Field] label/placeholder shake animation on input error #16634

Open
ghost opened this issue Jul 29, 2019 · 4 comments
Open

[Mat-Form-Field] label/placeholder shake animation on input error #16634

ghost opened this issue Jul 29, 2019 · 4 comments
Labels
area: material/form-field feature This issue represents a new feature or feature request rather than a bug or bug fix P4 A relatively minor issue that is not relevant to core functions

Comments

@ghost
Copy link

ghost commented Jul 29, 2019

Feature Description

See the example in the official docs:

In a form field, on error, the label/placeholder lightly shakes (left and right) as it turns red.

Use Case

This will enhance form field UX by subtly grabbing user attention for errors during form field entry

@ghost ghost added the feature This issue represents a new feature or feature request rather than a bug or bug fix label Jul 29, 2019
@ghost
Copy link
Author

ghost commented Jul 29, 2019

I haven't dived into the repo before but in the meantime here is the shake animation on my custom component that I wrapped around mat-form-field

animations: [
    trigger('errorShake', [
      state('0', style({})),
      state('1', style({})),
      transition('0 => 1', animate('450ms ease-out', keyframes([
        style({ transform: 'translateX(0px)', offset: 0 }),
        style({ transform: 'translateX(3.5px)', offset: 0.2 }),
        style({ transform: 'translateX(-2.25px)', offset: 0.4 }),
        style({ transform: 'translateX(1.25px)', offset: 0.6 }),
        style({ transform: 'translateX(-.5px)', offset: 0.8 }),
        style({ transform: 'translateX(0px)', offset: 1.0 }),
      ])))
    ])
  ]```

@andrewseguin andrewseguin added the P4 A relatively minor issue that is not relevant to core functions label Jul 31, 2019
@OlgaKavalenya
Copy link

OlgaKavalenya commented Sep 4, 2019

Hello @MMutch, I have the similar issue, only I need to remove animation from mat-form-field
I tried to create my custom component

import { Component } from '@angular/core';

@Component({
    selector: '[myWrapperTest]',
    template: '
    <mat-form-field></mat-form-field>    
  ',    
  animations: [
    trigger('transitionMessages', [
        
        state('enter', style({ opacity: 1, transform: 'translateY(0%)' })),
        transition('void => enter', [
            style({ opacity: 0, transform: 'translateY(-100%)' }),
            // animate('0ms'),
        ]),
    ])],
  })

  export class WrapperMatFormFieldComponent{
  }`

Then I tried to apply my wrapper 
`<form [formGroup]="myInfoForm" name="myInfoForm" class="MyInfo-container Form-textSelect">
      <mat-form-field myWrapperTest appearance="outline" class="MyModal-formField" required>
        <mat-label>Name <em>Required</em></mat-label>
        <input matInput formControlName="name" id="name">
        <mat-error>
          <ng-container *ngTemplateOutlet="nameErrors"></ng-container>
        </mat-error>
      </mat-form-field>
</form>`

If I apply wrapper to <mat-form-field>, I get the error 'Error: Template parse errors:
More than one component matched on this element.
Make sure that only one component's selector can match a given element.
Conflicting components: MatFormField,WrapperMatFormFieldComponent'.
When I apply it to <form> or <div>, it doesn't work (any changes) 

@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 21, 2022

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@angular-robot
Copy link
Contributor

angular-robot bot commented Mar 13, 2022

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/form-field feature This issue represents a new feature or feature request rather than a bug or bug fix P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

No branches or pull requests

2 participants