Skip to content

[Combobox] Improve long entries rendering with truncation  #5997

@dej611

Description

@dej611

Just leaving some feedback while refactoring some Lens code which uses the EuiComboBox with some long option strings.

The use case for the EuiComboBox is about selecting fields, which can have very long names, hence the need to provide a better rendering than the default behaviour in the combobox.
@mbondyra came up with this logic about computing the width of the element and passing such information into a truncation rendering component for the label:
Screenshot 2022-06-24 at 16 46 35

The logic adopted in Lens is available here: https://github.com/elastic/kibana/pull/134773/files#diff-6b4c7395f151e65267d98e78ea1944f51ea9fce2747f73e704ddadc00c666d81R51

It would be nice to have a truncation feature out of the box within the EuiComboBox component.
I can imagine an API like truncation: { width: number, ellipsis?: 'initial' | 'end' | 'middle' } | false where the width is used to automatically compute the font size and the ellipsis positioning.

Metadata

Metadata

Assignees

Labels

help wantedThe EUI team is unlikely prioritize. (Don't delete - used for automation)stale-issue(Don't delete - used for automation)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions