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

[Bug]: sp-combobox value is not equivalent to the currently selected menu item #4283

Open
1 task done
nickschaap opened this issue Apr 18, 2024 · 1 comment
Open
1 task done
Labels
bug Something isn't working Component: Combobox good first issue Good for newcomers triage An issue needing triage

Comments

@nickschaap
Copy link
Contributor

Code of conduct

  • I agree to follow this project's code of conduct.

Impacted component(s)

Combobox

Expected behavior

Let's say I have the following markup:

<sp-combobox size="m" label="Color">
    <sp-menu-item value="red">Red</sp-menu-item>
    <sp-menu-item value="green">Green</sp-menu-item>
    <sp-menu-item value="blue">Blue</sp-menu-item>
</sp-combobox>

I would expect that when I select the "Red" menu item in the combobox that the value of the comboxbox changes to red which is the value of the selected menu item.

Actual behavior

The sp-comboxbox value is Red which is the label of the menu item. Not the value.

Screenshots

No response

What browsers are you seeing the problem in?

Chrome

How can we reproduce this issue?

  1. Go to https://opensource.adobe.com/spectrum-web-components/components/combobox/#sizes
  2. Open the comboxbox, click "Red"
  3. Inspect the comboxbox element in the console
  4. Check the value of the combobox
  5. Observe that value as Red

Sample code that illustrates the problem

No response

Logs taken while reproducing problem

No response

@nickschaap nickschaap added bug Something isn't working triage An issue needing triage labels Apr 18, 2024
@Westbrook
Copy link
Collaborator

The Combobox is less a fancy <select> (as seen with Picker) than a fancy <input> (as seen with Textfield) and should maintain a value that is the same as what is visible at all times. This can be particularly important when accepting values that are not represented by Menu Items provided to the Combobox, due to open user input. The conversion from value to key, as available, is pretty straight forward and we would definitely be open to a contribution of a property along the lines of valueKey (or an even classier name) to surface in parallel a matched item key when present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Component: Combobox good first issue Good for newcomers triage An issue needing triage
Projects
None yet
Development

No branches or pull requests

3 participants