Skip to content

[FEATURE] Show noEntriesFoundLabel with an empty/none mat-option #463

@melroy89

Description

@melroy89

Is your feature request related to a problem? Please describe.

I added a "None" option (<mat-option>None</mat-option>), so users can select null/empty, whenever a select is not required (and if the user want to select nothing). So far so good.

However, this Angular component should ignore this specific mat-option since this option has no value attribute assign to it and therefor if no results are found the component should display the noEntriesFoundLabel text eg. "No matching ledger found" in my example.

Describe the solution you'd like

This Angular component should ignore the empty mat-option (mat-option without any value) and then still show me: "No search results" or "No matching ledger found" when the search did indeed return an empty array. Basically keep the noEntriesFoundLabel functionality working as expected.

Describe alternatives you've considered

I can't think of any, I follow the official Angular implementation to set a None option: https://material.angular.io/components/select/overview#form-field-features

Additional context

Due to the fact I have <mat-option>--</mat-option>, it will never show me the noEntriesFoundLabel text :(

<mat-select formControlName="transaction_ledger_id" placeholder="Ledger" width="100%">
  <mat-option>
    <ngx-mat-select-search formControlName="transaction_ledger_id_filter"
      placeholderLabel="Search..."
      noEntriesFoundLabel="No matching ledger found"
      [searching]="searching"></ngx-mat-select-search>
  </mat-option>
  <mat-option>--</mat-option>
  <mat-option *ngFor="let ledger of ledgers | async" [value]="ledger.ledger_id">
    {{ledger.ledger_number}} - {{ledger.ledger_description}}
  </mat-option>
</mat-select>`

And yes, I do want an empty mat-option in my drop-down.

Ideally, this None option should despite being at the top not be the default option when pressing "Enter" after a search.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions