Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: update

ecmadaocdb56351d888
diff --git a/frontend/src/components/HighlightLabelText.tsx b/frontend/src/components/HighlightLabelText.tsx
index ca5826d2c7..86e7bc1517 100644
--- a/frontend/src/components/HighlightLabelText.tsx
+++ b/frontend/src/components/HighlightLabelText.tsx
@@ -1,4 +1,4 @@
-import { getHighlightHTMLByRegExp } from "@/utils/util";
+import { escapeRegExp } from "lodash-es";
interface HighlightLabelTextProps {
text: string;
@@ -11,23 +11,29 @@ export function HighlightLabelText({
keyword,
className,
}: HighlightLabelTextProps) {
- const pattern: string | string[] =
+ const keywords =
typeof keyword === "string"
- ? keyword.trim()
+ ? [keyword.trim()].filter(Boolean)
: (keyword ?? []).map((k) => k.trim()).filter(Boolean);
- const isEmpty =
- typeof pattern === "string" ? pattern === "" : pattern.length === 0;
- if (isEmpty) {
+ if (keywords.length === 0) {
return <span className={className}>{text}</span>;
}
+
+ const pattern = keywords.map(escapeRegExp).join("|");
+ const parts = text.split(new RegExp(`(${pattern})`, "gi"));
+ const isMatch = new RegExp(`^(?:${pattern})$`, "i");
+
return (
- <span
- className={className}
- // getHighlightHTMLByRegExp escapes the input and sanitizes with
- // DOMPurify, so the returned string is safe to inject.
- dangerouslySetInnerHTML={{
- __html: getHighlightHTMLByRegExp(text, pattern),
- }}
- />
+ <span className={className}>
+ {parts.map((part, index) =>
+ isMatch.test(part) ? (
+ <b key={index} className="text-accent">
+ {part}
+ </b>
+ ) : (
+ part
+ )
+ )}
+ </span>
);
}
diff --git a/frontend/src/components/ui/combobox.test.tsx b/frontend/src/components/ui/combobox.test.tsx
index 06fc5023d2..1eb4b75bb0 100644
--- a/frontend/src/components/ui/combobox.test.tsx
+++ b/frontend/src/components/ui/combobox.test.tsx
@@ -6,6 +6,13 @@ import { Dialog, DialogContent } from "./dialog";
import { LAYER_BACKDROP_CLASS, LAYER_SURFACE_CLASS } from "./layer";
import { overlaySurfaceClassName } from "./styles.stylex";
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({
+ t: (key: string) =>
+ key === "common.load-more" ? "Load more" : key,
+ }),
+}));
+
(
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
).IS_REACT_ACT_ENVIRONMENT = true;