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

[TaxonomyPicker] errorMessage label not being removed #953

Closed
umaknow-jeanluc opened this issue Jul 9, 2021 · 2 comments
Closed

[TaxonomyPicker] errorMessage label not being removed #953

umaknow-jeanluc opened this issue Jul 9, 2021 · 2 comments
Labels
status:fixed-next-drop Issue will be fixed in upcoming release. type:bug
Milestone

Comments

@umaknow-jeanluc
Copy link
Contributor

Category

[ ] Enhancement

[x] Bug

[ ] Question

Version

Please specify what version of the library you are using: [latest]

Expected / Desired Behavior / Question

When using the errorMessage prop and reverting it to an empty string, it should remove the previous errorMessage

Observed Behavior

When clearing the errorMessage prop from the component, the previous errorMessage is not cleared. The componentWillReceiveProps method escapes the assignation of the new errorMessage only when there is a value.

TaxonomyPicker

public componentWillReceiveProps(nextProps: ITaxonomyPickerProps) {
    let newState: ITaxonomyPickerState | undefined;
    // Check if the initial values objects are not equal, if that is the case, data can be refreshed
    if (!isEqual(this.props.initialValues, nextProps.initialValues)) {
      newState = {
        activeNodes: nextProps.initialValues || []
      };
    }

    if (nextProps.errorMessage) {
      if (!newState) {
        newState = {};
      }

      newState.errorMessage = nextProps.errorMessage;
    }

    if (newState) {
      this.setState(newState);
    }
  }

Steps to Reproduce

  1. Create a component with the TaxonomyPicker
  2. Create a state with an errorMessage variable containing a non-empty random string
  3. Assign the errorMessage prop of the TaxonomyPicker with the state value previously assigned
  4. Create a button with an onClick that setState of the errorMessage with an empty string
  5. Notice that the errorMessage from the TaxonomyPicker is not cleared

Fix suggestion :
if (nextProps.errorMessage !== this.props.errorMessage) at line 93

Thanks!

@ghost
Copy link

ghost commented Jul 9, 2021

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 label Jul 9, 2021
@umaknow-jeanluc umaknow-jeanluc changed the title TaxonomyPicker errorMessage label not being removed [TaxonomyPicker] errorMessage label not being removed Jul 12, 2021
@AJIXuMuK
Copy link
Collaborator

AJIXuMuK commented Sep 2, 2021

Thank you @umaknow-jeanluc for reporting and fixing the issue.
The fix will be included in the next release.

@AJIXuMuK AJIXuMuK added status:fixed-next-drop Issue will be fixed in upcoming release. type:bug and removed Needs: Triage 🔍 labels Sep 2, 2021
@AJIXuMuK AJIXuMuK added this to the 3.4.0 milestone Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:fixed-next-drop Issue will be fixed in upcoming release. type:bug
Projects
None yet
Development

No branches or pull requests

2 participants