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

Fix value prop does nothing #244

Merged
merged 2 commits into from
Feb 10, 2024
Merged

Fix value prop does nothing #244

merged 2 commits into from
Feb 10, 2024

Conversation

Kysluss
Copy link
Collaborator

@Kysluss Kysluss commented Feb 10, 2024

Problem

According to the documentation, the value prop is supposed to make the component act like a controlled input. It doesn't appear to do anything.

Before Change

In order for a truly controlled component, you had to pass value to both AutoComplete and AutoCompleteInput. While this worked, it caused a lot of confusion with how the component worked. It also had the unintended consequence of making AutoCompleteInput always display the current value rather than the label of the item that was passed in.

After Change

Passing value to AutoComplete will now make this a controlled input as described by the documentation. If the value is changed outside of component, the AutoCompleteInput will correctly update with the label associated with the new value

Fixes #235

Copy link

changeset-bot bot commented Feb 10, 2024

⚠️ No Changeset found

Latest commit: 38ceebf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Kysluss Kysluss self-assigned this Feb 10, 2024
Copy link

what-the-diff bot commented Feb 10, 2024

PR Summary

  • New Variables Added to AutoCompleteInput Component
    The AutoCompleteInput component has been updated with two new variables: value and itemList. These were added to improve functionality and make the component more effective.

  • Enhancements to setQuery Logic
    The setQuery function within the AutoCompleteInput component has undergone a modification to now handle finding the correct item based on any provided value. This new logic enhances the component's ability to accurately retrieve the desired item.

  • New useEffect Hook
    There has been a newly added useEffect hook in the AutoCompleteInput component. This is to enable the setting of the query based on the inputValue, thereby providing a more efficient input-query process.

  • Addition of value Property to Type
    The type UseAutoCompleteReturn in the types.ts file has been expanded to include a new property: value. This helps capture additional detail about the autocomplete functionality.

  • New value Variable in useAutoComplete Hook
    A value variable was inserted into the useAutoComplete hook in the use-autocomplete.ts file. This addition further streamlines the autocomplete process by capturing specified values directly.

@Kysluss Kysluss added the bug Something isn't working label Feb 10, 2024
@Kysluss Kysluss merged commit 7941c9a into main Feb 10, 2024
1 check passed
@Kysluss Kysluss deleted the feature/fixValueProp branch February 10, 2024 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The value prop does nothing
1 participant