-
Notifications
You must be signed in to change notification settings - Fork 387
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
Dynamic form text, textarea and number fields clear values on blur after another field has been edited. #1923
Comments
Thank you for submitting your first issue to this project. |
I did some more testing and have found the issue also occurs when you open a debug (or production) edit form then:
Additionally if you click in a field with a value and edit it, it does NOT clear, but if you enter and leave without editing the field it DOES clear. |
Have you been able to check this issue? Our workaround is to override all the fields with this problem with fluent-ui-react components, which do not have the problem. |
@gchamplin we've encountered this issue as well, and I think we know which line(s) are responsible. It looks like this entire It is resetting the The If we remove the private onBlur = (): void => {
if (this.state.changedValue === null && this.props.defaultValue === "") {
this.setState({ changedValue: "" });
}
this.props.onChanged(this.props.columnInternalName, this.state.changedValue, true);
} to private onBlur = (): void => {
// If we have a changedValue, or the user has cleared out a field
// note: might need to amend this for complex values, array values, taxonomy values etc
if (this.state.changedValue || this.state.changedValue === "") {
// Notify DynamicForm and fire its onChange event
this.props.onChanged(this.props.columnInternalName, this.state.changedValue, true);
}
} This seems to fix the issue. I need to do more testing to confirm that doesn't break anything else. As for why those things are in there in the first place, I have to speculate really: Prior to a slight refactor that I contributed a couple of years ago, there were various props and state variables being used in In compiled code (in node_modules, If I get my dev branch up to date and test the above, I'll submit a PR. |
@t0mgerman thank you for taking a look at this. Making the two changes you suggested in DynamicField.js seems to solve the issue. We haven't seen any ill effects from the change; at least with a casual glance. We'll post back if we notice anything hinky. Thank you so much. |
@t0mgerman I want to second Rothrock's comments above, thanks so much for your help, so far so good. |
Category
[A dynamic form for a list with text, textarea, and number field inputs. loses values in those fields if you click or tab into the field and then click or tab out. This happens after you have edited another field. Or sometimes w/o even editing another field. This happens with no field overrides or other changes from the OOTB dynamic form. ] Bug
Version
I just updated to 3.20.0 and it's still happening
Please specify what version of the library you are using: [ 3.20.0 ]
Expected / Desired Behavior / Question
Expected behavior is for fields with values to retain those values on blur._
Observed Behavior
Observed behavior is text, textarea, and number fields losing value on blur.
Steps to Reproduce
Create a FormCustomizer and Dynamic form for an existing list with text, textarea, and number fields, and other fields as desired.
gulp serve the edit form and click in and out of a text field. It may retain its value, however, next edit another field and then click or tab into any text, textarea, or number field and then click or tab out of the field. The behavior we're seeing is the field losing focus will then also lose its value. Saving the form will update the input field as empty in the list.
The text was updated successfully, but these errors were encountered: