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: prop useLabels #1134

Closed
petlju opened this issue Jan 9, 2017 · 6 comments
Closed

Dropdown: prop useLabels #1134

petlju opened this issue Jan 9, 2017 · 6 comments

Comments

@petlju
Copy link

petlju commented Jan 9, 2017

Steps

prop useLabels set to false

Expected Result

http://semantic-ui.com/modules/dropdown.html#/examples
See the Without Labels example
Selected items are displayed as a count of selected items, so if 3 are selected it displays: "3 selected"
Selected items stay in the list with highlighted with bold text and they can be deselected by clicking them.

Actual Result

It is not yet implemented so useLabels currently does nothing

Version

0.63.5

Testcase

http://codepen.io/anon/pen/wgKzOb

@levithomason
Copy link
Member

Thanks for adding this per our gitter chat @petlju.

Here are direct links:
http://semantic-ui.com/modules/dropdown.html#maximum-selections (without labels)
http://semantic-ui.com/modules/dropdown.html#text-labels

Also, I like the idea of the comma separated list, although, I only find the feature to support a total count. Where exactly did you find the separated list with overflow ellipsis version?

http://g.recordit.co/4Ck9ucuOs4.gif

@petlju
Copy link
Author

petlju commented Jan 10, 2017

Ah, my bad. I had changed to that myself when looking at a way to accomplish useLabels. I must have glanced at the wrong window when I wrote the issue, sorry about that. Have updated the issue.

@jamesuejio
Copy link

jamesuejio commented Jul 28, 2017

Any update on this? Would really love to have the without labels feature in React. Also if there's any way of customizing the text that gets displayed that would be awesome similar to https://semantic-ui.com/modules/dropdown.html#text-labels

@levithomason
Copy link
Member

Would merge a PR from whoever needs this feature. I have no need or funding for it ATM and I haven't heard anything from the core team on it.

@levithomason
Copy link
Member

Closing this for housekeeping. Again, we'd love a PR from the community on this.

@thehappycoder
Copy link

My quick & dirty solution:

class MyMultiselectDropdown extends Dropdown {
  renderLabels = () => {
    return undefined
  }

  renderText = () => {
    const { placeholder, search } = this.props
    const { searchQuery } = this.state

    const hasSelectedValues = !!this.state.value.length

    const classes = cx(
      placeholder && !hasSelectedValues && "default",
      "text",
      search && searchQuery && "filtered"
    )

    return (
      <div className={classes} role="alert" aria-live="polite">
        {hasSelectedValues
          ? `${this.state.value.length} items`
          : this.props.placeholder}
      </div>
    )
  }
}

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

4 participants