Skip to content

[select] Integration with virtualization libraries #2282

@brianle1301

Description

@brianle1301

Feature request

Summary

I wanted to make Select.Popup a virtualized list. Works fine with mouse/pointer navigation, but keyboard navigation wouldn't focus on items past the virtualization window. This is a tricky issue to workaround, because Select builds its internal options array from Select.Item children, and only a handful are rendered at a time.

My suggestion would be to have an optional prop to hint Select of all of the options (or the total option count), and expose a way to get the current focused index, which can be used to scroll the virtualized window to that item.

Examples in other libraries

react-select has the options props, but their API philosophy is different to that of headless libraries:

 <Select
        className="basic-single"
        classNamePrefix="select"
        defaultValue={colourOptions[0]}
        isDisabled={isDisabled}
        isLoading={isLoading}
        isClearable={isClearable}
        isRtl={isRtl}
        isSearchable={isSearchable}
        name="color"
        options={colourOptions}
      />

Motivation

This is useful for rendering long lists or do infinite scrolling

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions