Skip to content

CustomSelectControl: refactor with ariakit #55023

@brookewp

Description

@brookewp

Context

Continuing with the exploration started by @ciampo in #41466, this issue will track the migration of CustomSelectControl to Ariakit.

Legacy: #55234
New version: #55790

Initial steps

  • Analyze the legacy component, learn how it works, take note of its features
  • Study Ariakit's Select component
  • Look into ARIA roles
  • Consider using WordPressComponentsProps CustomSelect: Add WordPressComponentsProps #56998
  • Create a new, temporary component which should implement:
    • children (and a CustomSelectControlV2.Item component) to allow its consumers to specify select options
    • basic functionality (value / onChange / defaultValue / label / size props)
    • styles that match the legacy component
    • Storybook docs and examples (maybe one with post authors)
  • Refine README, types stories, etc CustomSelect: Adapt component for legacy props #57902

V2 Legacy Wrapper

Completed in #57902

V2

To discuss

  • Review API surface:
    • Based on how much we expect V2 default to diverge from V2 legacy wrapper, does it make sense to keep a common underlying implementation, since it comes at the cost of higher complexity in the internal implementation
      • if so, let's see if there is a better way to allow different behavior / styles between the two versions (we currently use React context + passing props to Styled components)
    • Should the components forward refs? If so, should they expose multiple refs? (ie. to the label, the button, and the popover)
    • How to differentiate between props for wrapper vs props for trigger? Should we have a trigger render prop, like we do for DropdownMenuV2 ? (see CustomSelectControlV2: Add root element wrapper #62803 (comment)))
  • Popover behavior and APIS:
    • Should the popover be modal ? Regardless, should it always prevent body scroll?
    • Where should the popover render in the DOM ? Always inline? Always portal-ed ? If so, in which slot (see Popover-based UI: do not render in Popover.Slot by default #56482)? Should we expose any props?
      • This should influence / should be influenced by DropdownMenuV2 too
  • Consider cloning + splitting V1 and V2 implementations, so that V2 can diverge without affecting V1
  • Do we need an isMultiple prop? (especially when neither value nor defaultValue are specified, but also for TS ergonomics)
  • Discuss whether it makes sense to tweak the size of each item based on the pointer type (smaller items for fine pointer control, larger items for coarser pointer)
  • Discuss best approach to the select popover height (including the maximum and minimum heights) (see Improve CustomSelectControl's usability around max height #49110)
  • Discuss best approach to the select popover flip behavior (especially in the light of CustomSelectControl V2 popover renders below position: sticky elements #63180)
  • Consider adding new features (like exporting more subcomponents, separators, group and group labels, etc)
    • Including new Select-related components recently added to Ariakit
  • Ask design for specs/review
    • Should it have more specific prefix/suffix structure, similarly to the new DropdownMenuItem ?
    • Checkmark/SelectItemCheck
      • should it be optional?
      • should it be instead exported as a subcomponent, and used by consumers when needed?
      • placement:

        Should the design for CustomSelectItem be inspired by the work? Specifically; placing the checkmark icon on the left?

    • review line height (see comment)

To implement

To check before releasing

  • Public-facing docs (Types, Storybook examples, READMEs)
  • Export the component as private API, start experimenting in the editor
  • Check with accessibility folks on this and for overall feedback

Metadata

Metadata

Assignees

Labels

[Package] Components/packages/components[Type] Tracking IssueTactical breakdown of efforts across the codebase and/or tied to Overview issues.

Type

No type

Projects

Status

In progress (owned) ⏳

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions