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

SuperSelect components (HDS-3221) #2022

Merged
merged 147 commits into from
May 20, 2024
Merged

Conversation

KristinLBradley
Copy link
Contributor

@KristinLBradley KristinLBradley commented Mar 25, 2024

πŸ“Œ Summary

If merged, this PR will add SuperSelect components to HDS.

πŸ› οΈ Detailed description

API differences from PowerSelect:

  • @renderInPlace is always false (setting it to true makes the instances non-compliant and impossible to style via overrides)
  • On Multiple variants @closeOnSelect is always false allowing users to choose multiple options without requiring them to re-open the dropdown.
  • @searchPlaceholder is 'Search' by default

Form components

The following components will be available to our consumers:

  • Hds::Form::SuperSelect::Single::Base
  • Hds::Form::SuperSelect::Single::Field
  • Hds::Form::SuperSelect::Multiple::Base
  • Hds::Form::SuperSelect::Multiple::Field

The instantiation of SuperSelect::[Single|Multiple]::Base components is similar to the PowerSelect.

<Hds::Form::SuperSelect::Single::Base @ariaLabel="Label" as |option|>
  {{option}}
</Hds::Form::SuperSelect::Single::Base>

However, instantiating SuperSelect::[Single|Multiple]::Field components is slightly different because the Hds::Form::Field component exposes several subcomponents (Label, HelperText, Error).

<Hds::Form::SuperSelect::Single::Field as |F|>
  <F.Label>Label</F.Label>
  <F.Options>
    {{F.options}}
  </F.Options>
</Hds::Form::SuperSelect::Single::Field>

Note: Because the SuperSelect component doesn't use an HTML <input> element, the link between the label and the control is done via ariaLabelledBy meaning small updates were required for Form::Field and Form::Label components.

List positioning

There are two arguments related to positioning in PowerSelect:

  • @verticalPosition (unspecified/auto, below, above)
  • @horizontalPosition (left, center, right)

We tried to preserve PowerSelect's behavior for positioning as much as possible. Unfortunately, auto-positioning is only possible if the @renderInPlace is false (where the dropdown is placed at the root of the document, which is not a compliant option). For this reason, if no @verticalPosition is explicitly defined we rely on Floating UI via hds-anchored-position to automatically determine the positioning of the list.

List width

There are two arguments in SuperSelect:

  • matchTriggerWidth (default true, similar to PowerSelect)
  • dropdownMaxWidth (can be used to constrain the dropdown when matchTriggerWidth is false)

After options

Aside from PowerSelect's @afterOptionsComponent we added:

  • @afterOptionsContent (a way to provide custom content in the 'after options' section without requiring a component to be passed in)
  • @showAfterOptions (determines whether to display or not the 'after options' section)
    • default false in Single variants
    • default true in Multi variants

πŸ”— External links


πŸ‘€ Component checklist

πŸ’¬ Please consider using conventional comments when reviewing this PR.

Copy link

vercel bot commented Mar 25, 2024

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Updated (UTC)
hds-showcase βœ… Ready (Inspect) Visit Preview May 17, 2024 10:12am
hds-website βœ… Ready (Inspect) Visit Preview May 17, 2024 10:12am

The exceptions are still being worked on and need to be addressed in the main `ember-power-select` repo
The `__no-options-selected` element is now generated using the `Hds::Text::Body` component
For the style overrides where we instantiate `<PowerSelect>`
Co-authored-by: Majed Elass <[email protected]>
Co-authored-by: Melanie Sumner <[email protected]>
Co-authored-by: Jory Tindall <[email protected]>
Co-authored-by: Alex <[email protected]>
Co-authored-by: Majed <[email protected]>
Co-authored-by: Cristiano Rastelli <[email protected]>
@alex-ju
Copy link
Member

alex-ju commented May 17, 2024

@KristinLBradley @didoo It turns out that the <BasicDropdownWormhole /> is required even if we calculate the dropdown position using floating-ui, so I added a banner at the top highlighting this ember-power-select requirement in f54c713. Some products (such as Vault) already have it, but some don't so it's important to flag it upfront.

@KristinLBradley KristinLBradley merged commit 7c8cc20 into main May 20, 2024
16 checks passed
@KristinLBradley KristinLBradley deleted the hds-3221-super-select-component branch May 20, 2024 16:46
@hashibot-hds hashibot-hds mentioned this pull request May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-website Content updates to the documentation website packages/components showcase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants