How to force the Custom Trigger Text to update on multi MatSelect? #22627
Labels
area: material/select
troubleshooting
This issue is not reporting an issue, but just asking for help
What are you trying to do?
I created a reusable component that utilizes Material Multi Select.
What it does: It allows user to search the option results if there are more than 5 options.
The problem is that the Custom Trigger Text does not update when you search and uncheck all filtered results. I'm unsure of the exact reason, but I assume that Material is checking the
selectionChange
event's results (which are none) and doesn't know to update? Since I cannot rely on the results to be accurate from thisselectionChange
, I am overriding this by setting theselected
variable within the component with the correct selected results. As long as there is one checked box that is visible to the user, the Custom Trigger Text updates as expected.What are you trying to do?
I would like to FORCE the Custom Trigger Text to show the correct selected results (even if it's not visible to the user due to filtering from search)
What troubleshooting steps have you tried?
I have tried to research how to force this Custom Trigger to show the Selected results however I've been unsuccessful.
I have found that others have tried to do something similar such as here --> #7758
What are you seeing that does not match your expectations?
I would like to see the correct #of selected results in the Custom Trigger Text not the Placeholder (which should only show if there are 0 selected results)
Reproduction
Steps to reproduce:
^^^ I'm assuming that Angular's logic checks the
selectionChange
results and see's it as none right?Environment
Angular: 10.2.1
CDK/Material: 10.2.4
Browser(s): Chrome
Operating System (e.g. Windows, macOS, Ubuntu): macOS
NOTE: As a work around:
I am adding logic to change the placeholder text if
selected.length > 0
and adding a custom class to mat-select in order to style it to make it appear it's not the placeholder text but the custom trigger text.The text was updated successfully, but these errors were encountered: