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

[Select] Custom text for multiple selected values #6218

Closed
davidreher opened this issue Aug 2, 2017 · 7 comments
Closed

[Select] Custom text for multiple selected values #6218

davidreher opened this issue Aug 2, 2017 · 7 comments

Comments

@davidreher
Copy link

davidreher commented Aug 2, 2017

Bug, feature request, or proposal:

Feature request: Make it possible to adjust the text which is shown if multiple values are selected in MdSelect.

What is the expected behavior?

When all values are selected, the text is "[all] selected.
When more than 2 values are selected the text is "2 selected".

What is the current behavior?

All values are shown, seperated by ,, if they won't fit, ellipses are applied.

What are the steps to reproduce?

Go to the plunk and select all values.

What is the use-case or motivation for changing an existing behavior?

To our customers it is more useful to see how many values are selected (whether or not all are selected), rather than seeing only the first part of the text of the first selected item.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

master

Is there anything else we should know?

I already tried extending MdSelect. I think this is the best option, but I got stuck on all the errors in the (copied) template :(

Another option would be to have a callback as input property which is evaluated as part of triggerValue upon changes ...

I can also work on a PR if this is something which is required by others as well and if you have some guidance on the best option ...

@willshowell
Copy link
Contributor

Duplicate of #2275

@davidreher
Copy link
Author

I think this is somewhat different. Does it really solve my issue if I can specify how the selected values should be rendered? Still they will be concatenated or do I get it wrong?

@davidreher davidreher reopened this Aug 2, 2017
@willshowell
Copy link
Contributor

Yeah I see the distinction now, good call. I know I'd seen a similar request (#2722 (comment)) but it doesn't look like there's issue tracking for it yet!

@davidreher
Copy link
Author

@willshowell: Any ideas on the implementation? What would fit best? Should the text be included by material and then i18n-ized or should we have a callback?

@willshowell
Copy link
Contributor

I feel like a callback similar to autocomplete's displayWith is very comparable and makes sense for this. But if the default changes to "x, y, and 4 others" then it would certainly require internationalization.

davidreher added a commit to BROCKHAUS-AG/material2 that referenced this issue Aug 2, 2017
add input property to set a callback which will display a custom text if multiple values are selected. Similar to MdAutocomplete.displayWith.

fixes angular#6218
davidreher added a commit to BROCKHAUS-AG/material2 that referenced this issue Aug 2, 2017
add input property to set a callback which will display a custom text if multiple values are selected. Similar to MdAutocomplete.displayWith.

fixes angular#6218
davidreher added a commit to BROCKHAUS-AG/material2 that referenced this issue Aug 2, 2017
add input property to set a callback which will display a custom text if multiple values are selected. Similar to MdAutocomplete.displayWith.

fixes angular#6218
@davidreher
Copy link
Author

will be fixed by #3341

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants