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

Allow for selectedItem state change for placeholder #334

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cchalfan1
Copy link

I have not seen any issues with this, however I am probably not using all of the capabilities of this package.

I was having an issue where the placeholder would not change, even though the state for the placeholder of the parent component was changing. These changing props were not being seen because a condition a few lines above these changes were returning false when they should have been true.

Specifically:

const selectedItemChanged =
            !isEqual(nextProps.value, undefined) && !isEqual(prevState.selectedItem, selectedItem); // <= kept returning false because nextProps.value always seems to be undefined

        if (itemsChanged || selectedItemChanged) {
            if (selectedItemChanged) {
                nextProps.onValueChange(selectedItem.value, idx);
            }

            return {
                ...(itemsChanged ? { items } : {}),
                selectedItem
                // ...(selectedItemChanged ? { selectedItem } : {}),
            };
        }

At least, I figured this was worth the review.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants