I'm trying to extract the logic that filters and displays my mat-option
s for my mat-select
s into their own component. For some reason however, the options get displayed but clicking on them doesn't fire an event.
The web app I'm writing have a lot of mat-select
s which each potentially have a lot of mat-option
s. For obvious reasons, I need a way to filter the options so I'm using this node package. This pattern of "select with search field" appears a lot throughout the application, which is why I want to extract it into a component.
If all the code is contained in the same component, it works fine. The structure of this would look like this:
<select>
<option>
<search>
<option>
... more options
However, since I extract the search and option filtering into its own component, there's now a component between the select and its options like this:
<select>
<component> // Notice extra component
<option>
<search>
<option>
... more options
I've set up the simplest example I could think of for how I'm using the select: https://stackblitz.com/edit/select-option-generator
The example doesn't feature the search bar since that doesn't affect the behavior.
When you click on one of the first 3 options which are contained in the same component as the select, they get selected as expected. If you click on one of the last 3 options which are contained in the nested component inside the select, they get highlighted but don't get selected.
I'm trying to figure out why the options in the nested component don't get selected when they're clicked on.
Thanks in advance.