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

Support for ellipsis text in dropdown list components #1658

Closed
3 tasks
vivinkrishna-ni opened this issue Nov 10, 2023 · 0 comments · Fixed by #1669
Closed
3 tasks

Support for ellipsis text in dropdown list components #1658

vivinkrishna-ni opened this issue Nov 10, 2023 · 0 comments · Fixed by #1669
Assignees
Labels
enhancement New feature or request

Comments

@vivinkrishna-ni
Copy link
Contributor

vivinkrishna-ni commented Nov 10, 2023

😯 Problem to Solve

Components like nimble-listbox, nimble-select, and nimble-combobox display a list of options for selection. These options can include long text, and if the client wishes to limit the width of the overall component, the text may become clipped or hidden within the option. To address this, ellipsis (...) can be used to indicate truncated text for long strings within the option.

Relevant conversation: #1654 (comment)

  • Update the appropriate styles for nimble-combobox, nimble-select, nimble-listbox, and other components that utilize nimble-list-option
  • Add Storybook matrix test coverage for all the aforementioned components
  • Accessibility: If the ellipsis text is not visible, show a tooltip to display the full text

💁 Proposed Solution

Add text-overflow: ellipsis to the nimble-list-option content slot element (code link) like below:

.content {
    padding: 8px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

If client sets max-width or otherwise limits the width, text wraps

image

If sufficient space is available, some components can grow but it eventually looks silly

image

@vivinkrishna-ni vivinkrishna-ni added enhancement New feature or request triage New issue that needs to be reviewed labels Nov 10, 2023
@m-akinc m-akinc removed the triage New issue that needs to be reviewed label Nov 14, 2023
@mollykreis mollykreis self-assigned this Nov 15, 2023
mollykreis added a commit that referenced this issue Nov 27, 2023
# Pull Request

## 🤨 Rationale

Resolves #1658 

I also noticed that we had a workaround in the nimble-list-option for a
FAST issue that has been fixed upstream, so I removed the workaround and
validated that the issue is in fact fixed.

## 👩‍💻 Implementation

- Added styling to the nimble-list-option to ellipsis the content if it
gets too long
- Leverage existing `overflow` directive to the list option template so
that a `title` will be applied when the text is too long
- This required forking the FAST template for the list option, so in
addition to forking the template, I also brought in the FAST tests.

## 🧪 Testing

- Manually tested overflow behavior in storybook
- Manually tested that issue that had a workaround is still behaving as
expected with the workaround removed.
- Wrote new unit tests to verify the overflow/title behavior
- Brought in the FAST unit tests for the list option since the template
has now been forked

## ✅ Checklist

<!--- Review the list and put an x in the boxes that apply or ~~strike
through~~ around items that don't (along with an explanation). -->

- [ ] I have updated the project documentation to reflect my changes or
determined no changes are needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

3 participants