mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-11 16:31:57 +00:00
Fix: text highlight issue on search (#1850)
This commit is contained in:
parent
eda7222c9e
commit
b6d585fe51
@ -62,22 +62,15 @@ const SearchedData: React.FC<SearchedDataProp> = ({
|
|||||||
const highlightSearchResult = () => {
|
const highlightSearchResult = () => {
|
||||||
return data.map((table, index) => {
|
return data.map((table, index) => {
|
||||||
let tDesc = table.description;
|
let tDesc = table.description;
|
||||||
const highLightedTexts = !isEmpty(table.highlight?.description)
|
const highLightedTexts = table.highlight?.description || [];
|
||||||
? table.highlight?.description.join(' ') || ''
|
|
||||||
: '';
|
if (highLightedTexts) {
|
||||||
const highlightTxtMatch = highLightedTexts.match(
|
const matchTextArr = highLightedTexts.map((val) =>
|
||||||
/<span(.*?)>(.*?)<\/span>/g
|
|
||||||
);
|
|
||||||
if (highlightTxtMatch) {
|
|
||||||
const matchTextArr = highlightTxtMatch.map((val) =>
|
|
||||||
val.replace(/<\/?span(.*?)>/g, '')
|
val.replace(/<\/?span(.*?)>/g, '')
|
||||||
);
|
);
|
||||||
matchTextArr.forEach((text) => {
|
|
||||||
const regEx = new RegExp(`\\b${text}\\b`, 'g');
|
matchTextArr.forEach((text, i) => {
|
||||||
tDesc = tDesc.replace(
|
tDesc = tDesc.replace(text, highLightedTexts[i]);
|
||||||
regEx,
|
|
||||||
`<span class="text-highlighter">${text}</span>`
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -706,7 +706,7 @@ a:focus {
|
|||||||
|
|
||||||
.text-highlighter {
|
.text-highlighter {
|
||||||
background-color: #ffc34e40;
|
background-color: #ffc34e40;
|
||||||
padding: 0.25rem;
|
padding: 0 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
body .profiler-graph .recharts-active-dot circle {
|
body .profiler-graph .recharts-active-dot circle {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user