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

Dropdown: Customize selected label for single-select #852

Closed
jeffcarbs opened this issue Nov 14, 2016 · 3 comments · Fixed by #854
Closed

Dropdown: Customize selected label for single-select #852

jeffcarbs opened this issue Nov 14, 2016 · 3 comments · Fixed by #854

Comments

@jeffcarbs
Copy link
Member

jeffcarbs commented Nov 14, 2016

Background

For the Dropdown component in SUI-core, dropdown options can have both text and name properties to distinguish b/w how the option should look within the dropdown menu and how it should look as the selected item (see a more in depth description here: #682 (comment))

In my app I'm using a node for the text prop for each dropdown option to show more complex markup. Here's a rough example: http://codepen.io/jeffcarbs/pen/VmjmYo?editors=0010:
screen shot 2016-11-14 at 1 05 36 pm

For multi-select, you can now specify the renderLabel to customize how the selected items should be rendered.

There's no such equivalent to be able to customize how/what the single-select should render the selected item. In that same example, when you select something it renders the same complex node:
screen shot 2016-11-14 at 1 32 51 pm

I'd like it to show something else (e.g. just the simple text)

Question

Should/could we:

  • Enable specifying different text/name options (names of those props could change)?
  • Use the renderLabel for both single/multiple? The third argument to that function is the dropdown props so one could dynamically do something different for single/multiple.
  • Add a different render* function for that?

Thoughts?

@levithomason
Copy link
Member

levithomason commented Nov 14, 2016

I'm a little concerned about how far we're deviating from SUI core here. Since custom labels and custom dropdown items are not technically supported by SUI, they are working by chance really. There is no guarantee that an update shipped to SUI core today won't break this.

That said, we've come this far and the ability to have a correctly rendered single select seems like a must. I suppose we can always PR any conflicts that may arise in SUI core CSS due to our special usage here.

I think I am leaning toward number 3: "Add a different render* function for that?", but could you expound a bit on what you mean by number 1?

@jeffcarbs
Copy link
Member Author

@levithomason - just put up a PR with option 1, which is explained more clearly in the description of the PR. It's the approach that is supported by SUI-core so this should bring us more in line.

@levithomason
Copy link
Member

Perfect, will follow up there 👍

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

Successfully merging a pull request may close this issue.

2 participants