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

[component]: listbox #4020

Open
5 tasks done
alizedebray opened this issue Nov 19, 2024 · 2 comments · May be fixed by #4187
Open
5 tasks done

[component]: listbox #4020

alizedebray opened this issue Nov 19, 2024 · 2 comments · May be fixed by #4187
Assignees
Labels
📦 components Related to the @swisspost/design-system-components package
Milestone

Comments

@alizedebray
Copy link
Contributor

alizedebray commented Nov 19, 2024

Description

A listbox presents a list of options and allows a user to select one of them.

<post-listbox>
  <post-listbox-item>
    <post-icon name="3000"></post-icon>
    Option 1
  </post-listbox-item>
  <post-listbox-item>Option 2</post-listbox-item> 
</post-listbox>

Design

This component does not have a design, it must be configurable via CSS custom properties.

Requirements

Shadow DOM

This component does not make use of shadow DOM.

Styling options

  • --post-listbox-item-gap: Gap between listbox options
  • --post-listbox-heading-gap: Gap between heading (if shown) and the listbox

These options have not default definition but the can be set on the host by a user.
To achieve this, the following styling can be used:

:host {
  display: flex;
  gap: var(--post-listbox-gap); /* If this variable is defined (by the user) a gap will be set */
}

Props

  • title-hidden: the internal title container gets the class visually-hidden

Variants

  • No title: Title is visually hidden <post-list title-hidden>
  • Custom gap: <post-list style="--post-listbox-item-gap: 1rem; --post-listbox-heading-gap: 0.5rem">

Accessibility

https://www.w3.org/WAI/ARIA/apg/patterns/listbox/

  • The components need to have the correct aria-attributes, roles and keyboard navigation.
  • The list and the title have to be connected via aria-labelledby

Tasks development

💻 Development

Preview Give feedback
@alizedebray alizedebray added the 📦 components Related to the @swisspost/design-system-components package label Nov 19, 2024
@alizedebray alizedebray added this to the Design v2 milestone Nov 19, 2024
@gfellerph gfellerph moved this from 👀 Triage to 💡 Ready for token spec in Design System Production Board Nov 20, 2024
@alizedebray alizedebray moved this from 💡 Ready for token spec to 💻 Ready for development in Design System Production Board Nov 20, 2024
@myrta2302 myrta2302 self-assigned this Nov 25, 2024
@myrta2302 myrta2302 moved this from 💻 Ready for development to 🕹️ Coding in progress in Design System Production Board Dec 3, 2024
@myrta2302 myrta2302 changed the title [component]: single-select listbox [component]: listbox Dec 10, 2024
@myrta2302
Copy link
Contributor

myrta2302 commented Dec 12, 2024

Listbox Implementation

FOCUS (FOR SINGLE SELECT)
When a single-select listbox receives focus: either first option or last selected
(Keyboard Interaction - https://www.w3.org/WAI/ARIA/apg/patterns/listbox/)

FOCUS (FOR MULTISELECT)
When a multiselect listbox receives focus: either first option or first of selected options in the list (sorted list)
(Keyboard Interaction - https://www.w3.org/WAI/ARIA/apg/patterns/listbox/)

SELECTION (FOR SINGLE SELECT)
Selection follows focus (Note #3 - https://www.w3.org/WAI/ARIA/apg/patterns/listbox/

SELECTION (FOR MULTI SELECT)
Selection toggle with space (Keyboard Interaction - https://www.w3.org/WAI/ARIA/apg/patterns/listbox/

@myrta2302
Copy link
Contributor

Issue: Some times it first loads like this

...<post-listbox-item slot="post-listbox-item" role="option" tabindex="-1" data-hydrated="">Option 9</post-listbox-item>
      <post-listbox-item slot="post-listbox-item" role="option" tabindex="-1" data-hydrated="">Option 10</post-listbox-item>
    </div><div role="listbox" tabindex="0" aria-labelledby="listbox-bce8217b-80cc-4a1b-ab18-f5c5f069a0e0" aria-roledescription="This is an example listbox."></div></post-listbox>

@myrta2302 myrta2302 moved this from 🕹️ Coding in progress to 🤬 Dev in Code Review in Design System Production Board Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 components Related to the @swisspost/design-system-components package
Projects
Status: 🤬 Dev in Code Review
Development

Successfully merging a pull request may close this issue.

2 participants