From c9802d7a5ba9bb60828bc28827673db6bb0bf05f Mon Sep 17 00:00:00 2001 From: Alexis Georges Date: Sun, 19 Jan 2020 23:29:59 +0100 Subject: [PATCH] feat(stark-ui): route-search - add support for partial matching ISSUES CLOSED: #1335 --- .../route-search/components/route-search.component.spec.ts | 5 +++++ .../route-search/components/route-search.component.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/stark-ui/src/modules/route-search/components/route-search.component.spec.ts b/packages/stark-ui/src/modules/route-search/components/route-search.component.spec.ts index 6789af565e..9b6f25b7ef 100644 --- a/packages/stark-ui/src/modules/route-search/components/route-search.component.spec.ts +++ b/packages/stark-ui/src/modules/route-search/components/route-search.component.spec.ts @@ -208,6 +208,11 @@ describe("RouteSearchComponent", () => { expect(result.length).toBe(2); expect(result[0]).toEqual({ label: "Test 1", targetState: "test1", targetStateParams: undefined }); expect(result[1]).toEqual({ label: "Test 2", targetState: "test2", targetStateParams: undefined }); + + result = component.filterRouteEntries("st"); + expect(result.length).toBe(2); + expect(result[0]).toEqual({ label: "Test 1", targetState: "test1", targetStateParams: undefined }); + expect(result[1]).toEqual({ label: "Test 2", targetState: "test2", targetStateParams: undefined }); }); it("should return an empty array if the input is not in the list", () => { diff --git a/packages/stark-ui/src/modules/route-search/components/route-search.component.ts b/packages/stark-ui/src/modules/route-search/components/route-search.component.ts index fb3be2341e..df030e9c41 100644 --- a/packages/stark-ui/src/modules/route-search/components/route-search.component.ts +++ b/packages/stark-ui/src/modules/route-search/components/route-search.component.ts @@ -124,7 +124,7 @@ export class StarkRouteSearchComponent extends AbstractStarkUiComponent implemen routeEntry.label .toString() .toLowerCase() - .indexOf(filterValue) === 0 + .includes(filterValue) ); }