fixed #692 Search results are not showing the table description properly . (#714)

This commit is contained in:
Sachin Chaurasiya 2021-10-08 22:21:19 +05:30 committed by GitHub
parent d0661ccaf6
commit 37984f2822
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,9 +59,25 @@ const SearchedData: React.FC<SearchedDataProp> = ({
}: SearchedDataProp) => {
const highlightSearchResult = () => {
return data.map((table, index) => {
const description = isEmpty(table.highlight?.description)
? table.description
: table.highlight?.description.join(' ');
let tDesc = table.description;
const highLightedTexts = !isEmpty(table.highlight?.description)
? table.highlight?.description.join(' ') || ''
: '';
const highlightTxtMatch = highLightedTexts.match(
/<span(.*?)>(.*?)<\/span>/g
);
if (highlightTxtMatch) {
const matchTextArr = highlightTxtMatch.map((val) =>
val.replace(/<\/?span(.*?)>/g, '')
);
matchTextArr.forEach((text) => {
const regEx = new RegExp(`\\b${text}\\b`, 'g');
tDesc = tDesc.replace(
regEx,
`<span class="text-highlighter">${text}</span>`
);
});
}
const name = isEmpty(table.highlight?.table_name)
? table.name
@ -70,7 +86,7 @@ const SearchedData: React.FC<SearchedDataProp> = ({
return (
<div className="tw-mb-3" key={index}>
<TableDataCard
description={description}
description={tDesc}
fullyQualifiedName={table.fullyQualifiedName}
indexType={table.index}
name={name}