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

SelectableSearchInput state doesn't update when input changes #2773

Closed
ChristianMoll opened this issue Apr 10, 2024 · 3 comments · Fixed by #2776
Closed

SelectableSearchInput state doesn't update when input changes #2773

ChristianMoll opened this issue Apr 10, 2024 · 3 comments · Fixed by #2776
Labels
🐛 Type: Bug Something isn't working

Comments

@ChristianMoll
Copy link
Contributor

ChristianMoll commented Apr 10, 2024

Describe the bug

The SelectableSearchInput component has a state searchValue, this is displayed within the text input.
The component also accepts an input object value which has a property text.
If the text property of the value input changes the value that is sent when submitting the input does change but the shown value inside the input doesn't.
One simple way to avoid this would be to add a useEffect to the SelectableSearchInput to update the state when the input changes. i.E.

 useEffect(() => {
    setSearchValue(
      props.value.text
    );
  }, [props.value.text]);

To Reproduce
Steps to reproduce the behavior:

  1. Use the SelectableSearchInput
  2. Update the props.value.text through code
  3. Press enter or click the SearchIcon button
  4. The value being passed to the onSubmit handler is not the same being shown in the input.

Expected behavior
The shown value is in sync with the value that is sent on submitting.

@ChristianMoll ChristianMoll added the 🐛 Type: Bug Something isn't working label Apr 10, 2024
@CarlosCortizasCT
Copy link
Contributor

Hi @ChristianMoll

Thanks for letting us know about this issue.

Can we ask you please to provide an example use case where this scenario can be a problem? 🙏

@ChristianMoll
Copy link
Contributor Author

Hi @CarlosCortizasCT

Thanks for the fast response.

In our case it is a problem when we restore the state of the SelectableSearchInput from the myview in the customer search.

Other hypothetical scenarios could be restoring a form draft that uses a SelectableSearchInput when the user wants to continue with it or a SelectableSearchInput which is pre-filled based on the value of another input.

@CarlosCortizasCT
Copy link
Contributor

Related to this issue #2573

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants