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

First <sl-option> in <sl-select> is still highlighted when disabled #2342

Open
re1 opened this issue Jan 13, 2025 · 0 comments
Open

First <sl-option> in <sl-select> is still highlighted when disabled #2342

re1 opened this issue Jan 13, 2025 · 0 comments
Labels
bug Things that aren't working right in the library.

Comments

@re1
Copy link

re1 commented Jan 13, 2025

Describe the bug

In an <sl-select>, the first <sl-option> element will still be highlighted / focused if it is disabled through the disabled attribute.

With its styling being the same as an enabled option while in focus, the end user is unable to distinguish it from an enabled option without navigating to a different option.

The expected behavior, in my opinion, would be to focus the first enabled option instead.
I want to highlight that in it is not possible to focus disabled options in standard HTML (Chrome, Firefox), and that the first enabled option is selected by default.

To Reproduce

Steps to reproduce the behavior:

  1. Disable the first <sl-option> in an <sl-select> (see Demo)
  2. Click on the <sl-select> input
  3. See the first option highlighted

Demo

Adapted from an example in the docs: https://codepen.io/re1/pen/wBwjBLb.

<script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/[email protected]/cdn/shoelace.js"></script>

<sl-select label="Select one">
  <sl-option value="option-1" disabled>Option 1</sl-option>
  <sl-option value="option-2" disabled>Option 2</sl-option>
  <sl-option value="option-3">Option 3</sl-option>
</sl-select>

Screenshots

image

The first option is highlighted while being disabled. It is not possible to select it, it shows the disabled icon, and it is styled correctly when not highlighted.

Browser / OS

  • OS: Linux
  • Browser: Chromium, Firefox (likely all browsers)
  • Browser version: 131.0.6778.204, 134.0b10

Additional information

A colleague reported this as a bug in our application, stating the behavior as "unexpected" and "confusing". They also suggested that the first enabled option should be highlighted instead. I asked on Discord about this and was told to create an issue to discuss this.

@re1 re1 added the bug Things that aren't working right in the library. label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things that aren't working right in the library.
Projects
None yet
Development

No branches or pull requests

1 participant