Skip to content

Commit

Permalink
fix(ui): Fix Flickering Issue on search input field (#5503)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankit-Keshari-Vituity authored Jul 27, 2022
1 parent be296d6 commit 362b361
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions datahub-web-react/src/app/home/HomePageHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import { useHistory } from 'react-router';
import { Typography, Image, Row, Button, Tag } from 'antd';
import styled, { useTheme } from 'styled-components';
Expand All @@ -9,6 +9,7 @@ import { useEntityRegistry } from '../useEntityRegistry';
import { navigateToSearchUrl } from '../search/utils/navigateToSearchUrl';
import { SearchBar } from '../search/SearchBar';
import {
GetAutoCompleteMultipleResultsQuery,
useGetAutoCompleteMultipleResultsLazyQuery,
useGetSearchResultsForMultipleQuery,
} from '../../graphql/search.generated';
Expand Down Expand Up @@ -119,6 +120,13 @@ export const HomePageHeader = () => {
const user = useGetAuthenticatedUser()?.corpUser;
const themeConfig = useTheme();
const appConfig = useAppConfig();
const [newSuggestionData, setNewSuggestionData] = useState<GetAutoCompleteMultipleResultsQuery | undefined>();

useEffect(() => {
if (suggestionsData !== undefined) {
setNewSuggestionData(suggestionsData);
}
}, [suggestionsData]);

const onSearch = (query: string, type?: EntityType) => {
if (!query || query.trim().length === 0) {
Expand Down Expand Up @@ -212,7 +220,7 @@ export const HomePageHeader = () => {
<SearchBarContainer>
<SearchBar
placeholderText={themeConfig.content.search.searchbarMessage}
suggestions={suggestionsData?.autoCompleteForMultiple?.suggestions || []}
suggestions={newSuggestionData?.autoCompleteForMultiple?.suggestions || []}
onSearch={onSearch}
onQueryChange={onAutoComplete}
autoCompleteStyle={styles.searchBox}
Expand Down

0 comments on commit 362b361

Please sign in to comment.