components icon indicating copy to clipboard operation
components copied to clipboard

mat-select should be searchable

Open ArifRabbaniIn opened this issue 7 years ago • 8 comments

Feature Description

Provide support to search the available options, autocomplete feature.

aut

See (https://mseemann.io/angular2-mdl/select) for details

ArifRabbaniIn avatar Oct 30 '19 18:10 ArifRabbaniIn

This is very doable as is. It's not really their job to figure this out. and it's not a lot of code to do this.Heres a simple employee search

.TS:

ngOnInit() {
        this.employeeInfo$ = this.searchAssociates.pipe(
            debounceTime(300),
            distinctUntilChanged(),
            switchMap((searchValue: string) => this.searchService.EmployeeSearch(searchValue).pipe(
                map(res => _.uniq(res.employeeSearch)),
            )),
        );
   }

 public searchEmployees(searchValue: string): void {
        if (searchValue.length > 2) {
            this.searchAssociates.next(searchValue);
        }
    }

displayFn_employee(employee?: IEmployee): string | undefined {
        return employee ? employee.name : undefined;
    }

.HTML:

<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFunction ? displayFunction : displayFn_employee" (optionSelected)="onOptionSelected($event.option.value)">
    <mat-option *ngFor="let option of employeeInfo$ | async" [value]="option">
         {{ option.name }}
    </mat-option>
</mat-autocomplete>

sollenne avatar Oct 30 '19 19:10 sollenne

@sollenne with respect, I think you are missing the whole point of using components, probably most programmers who come here are able to create the whole angular material from scratch, give or take, but why we don't do it? because we all want to focus on our own business domain, and providing search for a combo box is not my domain problem, it's a must have need, but it's not specific to my domain, everybody needs it, so i think it should be part of the core.

gmareater avatar Oct 31 '19 00:10 gmareater

@gmareater he wants someone to write his code for him and I just did, and did it in an extremely easy-to-understand way. I have npm packages and understand that people will ask for features beyond the intent of the project. They made an awesome component and gave you the tools to scale it to your circumstance. An even easier way is to pull down all the state data and use that instead of making an api call on search but he didn’t ask for that. Giving me a thumbs down for helping him solve his problem by pointing out that he can already do what he’s requesting hardly seems worth the effort you put into your comment. Good job.

sollenne avatar Oct 31 '19 01:10 sollenne

Chill guys..

ArifRabbaniIn avatar Oct 31 '19 02:10 ArifRabbaniIn

@sollenne why r u making a big deal of it, it's a simple needed feature "Provide support to search the available options" sorry bro, but providing code and solution is for SO, here you agree or disagree to help maintainers decides it's needed or not. I will use your code for my problem, it's nice and acceptable but missing point in my belief is this: if i need this feature for almost all of my dropdowns, it should be part of framework. i hate to repeat myself.

gmareater avatar Oct 31 '19 04:10 gmareater

Guys, let the maintainers decide whether this feature is worth implementing. Peace

ArifRabbaniIn avatar Oct 31 '19 04:10 ArifRabbaniIn

Duplicate of #5697

jelbourn avatar Oct 31 '19 17:10 jelbourn

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.