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

[EuiComboBox] Allow dropdown to expand to not truncate options #2082

Closed
cjcenizal opened this issue Jun 29, 2019 · 16 comments
Closed

[EuiComboBox] Allow dropdown to expand to not truncate options #2082

cjcenizal opened this issue Jun 29, 2019 · 16 comments

Comments

@cjcenizal
Copy link
Contributor

This would solve the problem documented in elastic/kibana#36409

image

@chandlerprall
Copy link
Contributor

Took some time to look into this.

Complications

  • react-virtualized requires the width prop to be set, will not auto-expand to fit content
  • EuiComboBox is designed to size up to but not exceeding 400px. This governed by CSS.
  • The options' widths are set to fill the parent's space.
  • Options auto-truncate via CSS

Solution requirements

  • provide an exact width to react-virtualized
  • compute options' widths apart from the DOM values (can't inspect an element's clientWidth, for example)
  • update combobox CSS and JS to support both implementations

Proof of concept

I don't particularly like this approach, but wasn't able to come up with anything different. I also didn't try to reconcile the current max-width: 400px with the new setup, instead forcing all dropdowns to auto-fit their contents.

  • Measure rendered width of labels when the dropdown expands
    • allows options to be dynamic
    • waits for CSS to be downloaded/applied, important for including the correct font style
  • All browsers (only tested the PoC in Chrome) support CanvasRenderingContext2D.measureText()
  • Canvas context needs to have the correct font style applied
    • the PoC cheats here by assuming the input box's font is the same size as the options list

Changes can be viewed at master...chandlerprall:feature/expanding-combobox-dropdown

proof of concept

@cchaos
Copy link
Contributor

cchaos commented Jul 12, 2019

My thoughts:

A. I don't think it's ok to expand the dropdown's width indefinitely. There will be many issues that will arise from this including going completely off screen.

Screen Shot 2019-07-11 at 22 30 20 PM

B. That being said we could give it a default max-width of 400px allowing the dropdown to grow to 400px even if the input is narrower.

C. However, that would mean we need to change some styles of the dropdown quite a bit and would want to consider centering the dropdown to the input.

Something like, but not enamored by:

Screen Shot 2019-07-11 at 22 37 27 PM

@kertal
Copy link
Member

kertal commented Nov 28, 2019

since this is coming in frequently from different sources, solving this would be great. at least it the max width should be configureable, would also help. many thanks

@cchaos cchaos self-assigned this Sep 18, 2020
@cchaos cchaos changed the title Option to allow EuiComboBox dropdown to expand to not truncate options [EuiComboBox] Allow dropdown to expand to not truncate options Sep 20, 2020
@lizozom
Copy link
Contributor

lizozom commented Oct 29, 2020

Any updates on this by any chance?

@chandlerprall
Copy link
Contributor

@cchaos what about something like this?

combobox_listoption_expansion

@cchaos
Copy link
Contributor

cchaos commented Oct 30, 2020

Yeah I've mostly dropped the ball on this because it's actually a harder problem to solve than it seems on the surface.

@lizozom We'll make sure a solution is done in this minor (7.11)

@cjcenizal
Copy link
Contributor Author

@chandlerprall I think one issue with that solution could be that it requires "looking with your mouse", instead of your eyes. To get a sense for how that could be a frustrating UX, consider the screenshot in the description but with many fields that share the same stem, e.g. customer_first_name, customer_first_name_raw, customer_first_name_translated_fr, and so on. It'd be time-consuming to hunt through all of them with your mouse in order to find the one you want.

@cchaos
Copy link
Contributor

cchaos commented Nov 3, 2020

We're currently looking into a solution that would allow the option labels to wrap, but hinders on the ability from the plugin we use for virtualization. Otherwise a couple solutions we'll also look into are:

  1. Middle truncation
  2. Customizing width of popover

Most of the solutions will be opt-in, meaning there will still need to be follow up by Kibana. Another piece of this will be that the field selector in Kibana should just be full width of the containing popover instead of 50% and/or extend the width of that popover.

@AlonaNadler
Copy link

I got another request from a customer about this issue, they are struggling with selecting the right index pattern in discover. Their index pattern have long names that get truncated. I can't share the screenshot since it contains sensitive information

@cchaos
Copy link
Contributor

cchaos commented Dec 10, 2020

With elastic/kibana#85320 merged, this is no longer urgent, but I'm still leaving open in hopes we can find a solution during a refactor to using EuiSelectable.

@cchaos cchaos removed the !urgent! label Dec 10, 2020
@cchaos cchaos removed their assignment Dec 10, 2020
@github-actions
Copy link

github-actions bot commented Jun 9, 2021

👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.

@cjcenizal
Copy link
Contributor Author

Still seems like an issue users will run into, so worth keeping this open?

@wylieconlon
Copy link

@cchaos I like the options you suggested of either middle truncation or expanded popover width. Were you suggesting that the combo box should support both options, or that we should pick one as the preferred solution? Would this be something open to a contribution from Lens?

We recently ran into this in the Lens field list: elastic/kibana#103701

@snide
Copy link
Contributor

snide commented Aug 16, 2021

Small note that elastic/kibana#106285 implemented some logic within Lens for this. We might want to consider building this in directly through a truncate prop on the EUI components directly.

@daveyholler
Copy link
Contributor

Closing this as not-planned and in favor of #5997

@JasonStoltz
Copy link
Member

JasonStoltz commented Oct 11, 2023

#7246 Introduces a min-width prop that will allow this dropdown to expand independently of the width of the dropdown element, which solves this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants