diff --git a/examples/example-app-angular-cli/package.json b/examples/example-app-angular-cli/package.json index 116d57fc..b767c487 100644 --- a/examples/example-app-angular-cli/package.json +++ b/examples/example-app-angular-cli/package.json @@ -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", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 94ef95b9..31f5ee9b 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -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(); diff --git a/src/app/shared/highlight-search-match.pipe.ts b/src/app/shared/highlight-search-match.pipe.ts index 2b66545d..51f52169 100644 --- a/src/app/shared/highlight-search-match.pipe.ts +++ b/src/app/shared/highlight-search-match.pipe.ts @@ -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, []);