TextFiled: this._willMountTriggerValidation is removed and caused regression
Bug Report
- Package version(s): office-ui-fabric-react_v1.13.0
Describe the issue:
We found in this commit: https://github.com/OfficeDev/office-ui-fabric-react/commit/4dd5704695305c6b76608b14416edb1223ca0675, this._willMountTriggerValidation is removed. It caused a regression that _notifyAfterValidate will trigger the onChange event. Because it's the first time rendering, it's supposed not to trigger onChange.
Actual behavior:
Trigger onChange when it will mount.
Expected behavior:
Don't trigger onChange when it will mount.
This should be fixed in latest release with https://github.com/OfficeDev/office-ui-fabric-react/commit/e09761c2a2b4b28386f2854fe33555578029f360.
About "onChanged" and "onNotifyValidationResult":
- previous behavior: after done the validation: 1, call onNotifyValidationResult; 2. If no error, call onChanged.
- current behavior: 1, before doing the validation, call onChanged; 2. after done validation, call onNotifyValidationResult.
It's different logic now, I afraid it would break lots of existing code which would dependent on previous behavior.
My suggestion is:
- keep the previous behavior.
- if we need some callback function be called, before doing the validation, we can add a new interface property.
There was an issue reported where onChanged didn't trigger since there was no error and its the reaction work for the same. Current behavior is the desired one and more intuitive perhaps. OnChanged shouldn't be dependent on validation or validation error. I can have a TextField with onChanged without any validation provider or onNotifyValidation. IMHO, the earlier flow was misleading without any proper documentation. There might be instances where it may break consumers but its better we address it rather than keep supporting a buggy behavior.
@YusongLiu , @liuqingbo hope you are able to correct the behavior using the new flow. You can re-open this if you think the behavior is not correct. Thanks