Skip to content

Customize ld-select selected options rendering #637

@borisdiakur

Description

@borisdiakur

Discussed in #633

Originally posted by dpitois April 12, 2023
Hi!

I was looking for available options to customize how the selected options are rendered when using the ld-select (with multiple enabled).
Did not find another issue or question about that, if I missed it, sorry, and I will try to inspire from that.

My need is to render options in the popover using a LaTeX wrapper, and so far for now, I can put custom HTML inside the ld-option, the rendering is working as expected.
But, when we select an option (or more), it looks like only the .innerText part is taken and renderer in parent ld-select component.

Is there a way to take hand on how is rendered this selection?

Example: https://stackblitz.com/edit/github-fvtkeq?file=src%2Fcomponents%2FForm%2FForm.tsx
I took the React sandbox, and just add the following code to the theme option part in order to add a red square:

<div
  style={{
    width: '1em',
    height: '1em',
    display: 'inline-block',
    backgroundColor: 'red',
    marginRight: '1em',
  }}
></div>

It looks OK for the popover:

image

but only the text part is visible on selection:

image

Metadata

Metadata

Assignees

Labels

acceptedIssues with this label are issues that the core team has accepted on to the roadmap.featureIssues that describe new features.released

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions