Giter VIP home page Giter VIP logo

Comments (11)

JeanMeche avatar JeanMeche commented on May 4, 2024 1

I'll close this as a dupe of #45015

from angular.

JeanMeche avatar JeanMeche commented on May 4, 2024

Hi, your stackblitz repro doesn't produce any issues. Can you please have a look. Thank you.

from angular.

DywiTom avatar DywiTom commented on May 4, 2024

Sorry i fixed the compile problems.

Open console and clear it.
Click on any control and lose focus.
Blur event should be triggerd.

from angular.

JeanMeche avatar JeanMeche commented on May 4, 2024

I see logs on blur, which is what should happen.
What exactly do you expect updateOn: 'blur', to do ?

from angular.

DywiTom avatar DywiTom commented on May 4, 2024

Normaly it should call the custom validator after bluring. It doesn't do that.

  1. Start server
  2. Clear console
  3. Click on control
  4. Lose focus (blur event)
  5. Validator should be called and console.log should be visible

no call

For example how does Validators.required do that?
After bluring (without changing input) it shows required

from angular.

geromegrignon avatar geromegrignon commented on May 4, 2024

There are no pending changes to be evaluated in the example shown in your video.
With blur strategy, Angular expects changes upon the field value to update it and run validators.

from angular.

DywiTom avatar DywiTom commented on May 4, 2024

How does for example Validators.required do that?
It doesn't requiere any changes to fire the "require" error.

from angular.

geromegrignon avatar geromegrignon commented on May 4, 2024

As you can see in your console, there are logs at the form init. That's about the same for required.
By blurring from it without any changes, it was already in error.

How do you see "it shows" or "fire the error"?

from angular.

DywiTom avatar DywiTom commented on May 4, 2024

My expectation with "updateOn: 'blur'" is that the validators should be executed again, otherwise it should better be called "updateOn: 'change'". That is confusing.

Let's say I click on a FormControl with Validators.required and I don't change anything. If I then click on something else, I see the mat-error. But this does not apply to my custom validators because they are not executed again.

from angular.

geromegrignon avatar geromegrignon commented on May 4, 2024

mat-error internally only displays if the field has been touched.
It's about the same for your validators. If the control was invalid before blurring without any change, the error will appear.

If you need to update the validity of some field based on a parent one, use a validator on the parent itself.

from angular.

DywiTom avatar DywiTom commented on May 4, 2024

Ok guys, thanks for your answers

from angular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.