X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/d38fcf4f5b9d8a1889b9bdf79ee77a2022ed4b52..bc311e9eb8d6b0e4850823d4a9acd29d6176d06b:/src/views-components/search-bar/search-bar-autocomplete-view.tsx

diff --git a/src/views-components/search-bar/search-bar-autocomplete-view.tsx b/src/views-components/search-bar/search-bar-autocomplete-view.tsx
index fb3e895da8..8529450902 100644
--- a/src/views-components/search-bar/search-bar-autocomplete-view.tsx
+++ b/src/views-components/search-bar/search-bar-autocomplete-view.tsx
@@ -6,30 +6,39 @@ import * as React from 'react';
 import { Paper, StyleRulesCallback, withStyles, WithStyles, List } from '@material-ui/core';
 import { RecentQueriesItem } from '~/views-components/search-bar/search-bar-view';
 import { GroupContentsResource } from '~/services/groups-service/groups-service';
+import Highlighter from "react-highlight-words";
 
-type CssRules = 'list';
+type CssRules = 'list' | 'searchView';
 
 const styles: StyleRulesCallback<CssRules> = theme => {
     return {
         list: {
-            padding: '0px'
+            padding: 0
+        },
+        searchView: {
+            borderRadius: `0 0 ${theme.spacing.unit / 2}px ${theme.spacing.unit / 2}px`
         }
     };
 };
 
 export interface SearchBarAutocompleteViewDataProps {
     searchResults?: GroupContentsResource[];
+    searchValue?: string;
 }
 
 type SearchBarAutocompleteViewProps = SearchBarAutocompleteViewDataProps & WithStyles<CssRules>;
 
 export const SearchBarAutocompleteView = withStyles(styles)(
-    ({ classes, searchResults }: SearchBarAutocompleteViewProps ) =>
-        <Paper>
-            {searchResults &&  <List component="nav" className={classes.list}>
-                {searchResults.map((item) => {
-                    return <RecentQueriesItem key={item.uuid} text={item.name} />;
+    ({ classes, searchResults, searchValue }: SearchBarAutocompleteViewProps) =>
+        <Paper className={classes.searchView}>
+            {searchResults && <List component="nav" className={classes.list}>
+                {searchResults.map((item: GroupContentsResource) => {
+                    return <RecentQueriesItem key={item.uuid} text={getFormattedText(item.name, searchValue)} />;
                 })}
             </List>}
         </Paper>
-);
\ No newline at end of file
+);
+
+const getFormattedText = (textToHighlight: string, searchString = '') => {
+    return <Highlighter searchWords={[searchString]} autoEscape={true} textToHighlight={textToHighlight} />;
+};
\ No newline at end of file
