From e774d4d8c328171053290470fd0759306b8d12c4 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 29 Nov 2018 16:59:03 -0700 Subject: [PATCH] Populate query box from url. Fixes #18. --- server/ui/src/components/navbar.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/ui/src/components/navbar.tsx b/server/ui/src/components/navbar.tsx index 0a260a4..38e3200 100644 --- a/server/ui/src/components/navbar.tsx +++ b/server/ui/src/components/navbar.tsx @@ -18,6 +18,7 @@ export class Navbar extends Component { constructor(props, context) { super(props, context); + this.fillSearchField(); } render() { @@ -72,4 +73,13 @@ export class Navbar extends Component { } i.setState({ searchParams: searchParams }); } + + fillSearchField() { + let splitPath: Array = this.context.router.route.location.pathname.split("/"); + if (splitPath.length == 4 && splitPath[1] == 'search') + this.state.searchParams = { + page: Number(splitPath[3]), + q: splitPath[2] + }; + } }