Skip to content

[EuiComboBox] Allow custom render of selected items #2358

Closed

Description

@cchaos

Right now the combobox allows you to pass a custom render for the options in the list but you can't replicate that render in the input itself when an option is selected.

Example: Icon list

It would be very beneficial to also show the icon in the input.

Screenshot 2022-02-11 at 09 48 54

Both Maps and Graph use this icon selection technique.

Activity

  1. cchaos commented on Sep 20, 2019

    @cchaos
    ContributorAuthor
  2. cchaos commented on Sep 24, 2019

    @cchaos
    ContributorAuthor

    We discussed this, and the best way to handle it is to use the same render method as provided for the options (if possible, have to look at the code) or just provide another custom render method for the selected option.

  3. self-assigned this
    on Sep 24, 2019
  4. chandlerprall commented on Sep 25, 2019

    @chandlerprall
    Contributor

    I think we'll want to add a custom rendering function to this - naively reusing the existing renderOption in our docs renders as

    renderOption reuse

    There is another level of effort here as the rendered content will need to be processed (e.g. with EuiInnerText) to pass it in as the iconOnClickAriaLabel.

  5. removed their assignment
    on Mar 18, 2020
  6. changed the title [-]EuiComboBox to allow custom render of selected items[/-] [+][EuiComboBox] Allow custom render of selected items[/+] on Sep 20, 2020
  7. github-actions commented on Mar 19, 2021

    @github-actions

    👋 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.

  8. added
    stale-issue
    on Mar 19, 2021
  9. flash1293 commented on Mar 19, 2021

    @flash1293
    Contributor

    Bump - this is still valid.

  10. removed
    stale-issue
    on Mar 19, 2021
  11. 1 remaining item

  12. added
    stale-issue
    on Sep 15, 2021
  13. added and removed
    stale-issue
    on Sep 15, 2021
  14. nreese commented on Sep 15, 2021

    @nreese
    Contributor

    Bump - this is still valid.

  15. tilman commented on Oct 15, 2021

    @tilman

    This issue is now open for 2 years. Is there any work planned or workaround avalaible?

  16. cchaos commented on Feb 11, 2022

    @cchaos
    ContributorAuthor

    Closing this old issue in favor of #5628 which contains working screenshots and a workaround until we can solve it internally.

  17. JasonStoltz commented on Jan 17, 2023

    @JasonStoltz
    Contributor

    Reopening as this is more representative of the work we'd like to do, rather than #5628

  18. self-assigned this
    on Jul 17, 2023
  19. self-assigned this
    on Jul 19, 2023
  20. cee-chen commented on Jul 19, 2023

    @cee-chen
    Contributor

    An update on the approach taken for this issue. Based on the requested use-cases, we've decided to resolve this request (made by @shahzad31 and other Elastic teams) via copying EuiSelectable's option.prepend and option.append API (see docs).

    The largest reason for this is because EuiComboBox is eventually going to adopt EuiSelectable under the hood (see #2841) for accessibility. The closer we can get to EuiSelectable's existing API, the easier that migration will be. Additionally, adopting existing APIs and patterns leads to a more consistent developer experience and is generally preferable over introducing one-offs where possible.

    All the mentioned Kibana use cases have primarily been around adding icon rendering, which prepend/append nodes should easily solve. If in the future, consumers truly need a totally custom render method for EuiComboBox's pills, we can revisit that choice at that point (in a new issue). However, I want to add my 2c that if that does happen, we should likely prefer to add a new renderPill API rather than bogarting renderOption. This is so consumers currently using renderOption don't suddenly and unexpectedly see a change in their pill rendering without them changing any props.

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions