fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

TextFiled: this._willMountTriggerValidation is removed and caused regression

Open YusongLiu opened this issue 9 years ago • 4 comments

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.

YusongLiu avatar Mar 06 '17 08:03 YusongLiu

This should be fixed in latest release with https://github.com/OfficeDev/office-ui-fabric-react/commit/e09761c2a2b4b28386f2854fe33555578029f360.

mdahamiwal avatar Mar 06 '17 09:03 mdahamiwal

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:

  1. keep the previous behavior.
  2. if we need some callback function be called, before doing the validation, we can add a new interface property.

liuqingbo avatar Mar 07 '17 11:03 liuqingbo

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.

mdahamiwal avatar Mar 07 '17 21:03 mdahamiwal

@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

mdahamiwal avatar Mar 15 '17 11:03 mdahamiwal