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(Dropdown): update selectedId when selectedIndex changes. #611

Merged
merged 1 commit into from
Apr 24, 2021

Conversation

DavidEspinosa42
Copy link
Contributor

Hi guys!
Using the dropdown we found a visual bug.
When we change the selectedIndex value from an external action like clicking a button, we can see the previously selected item active when we open the dropdown.

Here's a Minimal, Reproducible Example: https://svelte.dev/repl/159395c52c3140f996616b57d74861f4?version=3.37.0

Just wait for it to compile then:
Click the dropdown.
Click the third item.
Click the button that changes the selectedIndex.
Click the dropdown.

You will see the 2nd AND 3rd item active!
You should only see the 2nd 😅
This PR updates the internal selectedId variable when a valid selectedIndex is passed, otherwise, it sets it to undefined (its initialization value).

@vercel
Copy link

vercel bot commented Apr 23, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/carbon-svelte/carbon-components-svelte/GuxSNUW2g26b1Fu5mXzTK9gqf4qV
✅ Preview: https://carbon-compone-git-fork-davidespinosa42-master-carbon-8d8f55.vercel.app

Copy link
Collaborator

@metonym metonym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch – thank you.

@metonym metonym merged commit 2013120 into carbon-design-system:master Apr 24, 2021
@metonym
Copy link
Collaborator

metonym commented Apr 24, 2021

Published to NPM in version v0.32.2

metonym added a commit that referenced this pull request Apr 24, 2021
* feature: Add support for nested object fields in Data Table

feature: Add support for nested object fields in Data Table

* fix can't open dropdown with keyboard (#610)

* fix(Dropdown): update selectedId when selectedIndex changes. (#611)

* chore(deps-dev): patch carbon-components@10.32.1 (#613)

* v0.32.2

* feature: Add support for nested object fields in Data Table

feature: Add support for nested object fields in Data Table

* chore: Added example for nested object values into the documentation

Co-authored-by: Lyu, Wei-Da <36730922+jasonlyu123@users.noreply.github.com>
Co-authored-by: David Espinosa <david.emanuel.espinosa@gmail.com>
Co-authored-by: Eric Liu <ericyl.us@gmail.com>
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.

2 participants