Skip to content

Show all components on empty search #65

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

Merged
merged 3 commits into from
Nov 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/example-app-angular-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"playground:copy": "node ../../scripts/copy.js",
"playground:run": "node ./node_modules/angular-playground/dist/bin/cli.js",
"playground": "npm run playground:copy && npm run playground:run",
"playground:dev": "npm run build --prefix ../../ && npm run playground",
"playground2:run": "node ./node_modules/angular-playground/dist/bin/cli.js angular-playground2.json",
"cli": "ts-node --project ../../src/cli ../../src/cli/cli.ts",
"cli:build": "ts-node --project ../../src/cli ../../src/cli/cli.ts -no-watch -no-serve",
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,12 @@ export class AppComponent {

private filterSandboxes(sandboxMenuItems: SandboxMenuItem[], filter: string) {
if (!filter) {
return [];
return sandboxMenuItems.map((item, i) => Object.assign({}, item, { tabIndex: i }));
}

let tabIndex = 0;
let filterNormalized = filter.toLowerCase();

return sandboxMenuItems
.reduce((accum, curr) => {
let searchKeyNormalized = curr.searchKey.toLowerCase();
Expand Down
5 changes: 4 additions & 1 deletion src/app/shared/highlight-search-match.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'apHighlightSearchMatch', pure: false})
export class HighlightSearchMatchPipe implements PipeTransform {
transform(value: string, indexMatches: number[], offset = 0): any {
if (value == null) return value;
// Match null and undefined, but not 0 or ''
if (value == null || indexMatches == null) {
return value;
}

let transformedValue = '';
let indexes = indexMatches.reduce((a, n) => n >= offset ? [...a, n - offset] : a, []);
Expand Down