Skip to content

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

fix: overlapping input borders (#21620)

ecmadao3e41f6219b39
diff --git a/frontend/src/components/LabelListEditor.tsx b/frontend/src/components/LabelListEditor.tsx
index e0cd244028..94328112c3 100644
--- a/frontend/src/components/LabelListEditor.tsx
+++ b/frontend/src/components/LabelListEditor.tsx
@@ -129,7 +129,7 @@ export function LabelListEditor({
<Input
value={kv.key}
placeholder={t("setting.label.key-placeholder")}
- className={errors.key.length > 0 ? "border-error" : ""}
+ aria-invalid={errors.key.length > 0 || undefined}
onChange={(event) => updateKey(index, event.target.value)}
/>
)}
@@ -151,9 +151,7 @@ export function LabelListEditor({
<Input
value={kv.value}
placeholder={t("setting.label.value-placeholder")}
- className={
- errors.value.length > 0 ? "border-error" : ""
- }
+ aria-invalid={errors.value.length > 0 || undefined}
onChange={(event) =>
updateValue(index, event.target.value)
}
diff --git a/frontend/src/components/ui/input.test.tsx b/frontend/src/components/ui/input.test.tsx
new file mode 100644
index 0000000000..0a0986a811
--- /dev/null
+++ b/frontend/src/components/ui/input.test.tsx
@@ -0,0 +1,38 @@
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, test } from "vitest";
+import { Input } from "./input";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+describe("Input", () => {
+ let container: HTMLDivElement;
+ let root: ReturnType<typeof createRoot>;
+
+ beforeEach(() => {
+ container = document.createElement("div");
+ document.body.appendChild(container);
+ root = createRoot(container);
+ });
+
+ afterEach(() => {
+ act(() => root.unmount());
+ container.remove();
+ });
+
+ test("uses an inset error focus ring when invalid", () => {
+ act(() => {
+ root.render(<Input aria-invalid="true" />);
+ });
+
+ const input = container.querySelector("input");
+ expect(input).not.toBeNull();
+ expect(input?.className).toContain("aria-invalid:border-error");
+ expect(input?.className).toContain("aria-invalid:focus:border-error");
+ expect(input?.className).toContain("aria-invalid:focus:ring-1");
+ expect(input?.className).toContain("aria-invalid:focus:ring-error/30");
+ expect(input?.className).toContain("aria-invalid:focus:ring-inset");
+ });
+});
diff --git a/frontend/src/components/ui/input.tsx b/frontend/src/components/ui/input.tsx
index 1136aa2fa6..0da3875ddf 100644
--- a/frontend/src/components/ui/input.tsx
+++ b/frontend/src/components/ui/input.tsx
@@ -9,7 +9,7 @@ const inputVariants = cva(
cn(
"flex w-full rounded-xs border border-control-border bg-transparent text-main transition-colors",
"placeholder:text-control-placeholder",
- "aria-invalid:border-error",
+ "aria-invalid:border-error aria-invalid:focus:border-error aria-invalid:focus:ring-1 aria-invalid:focus:ring-error/30 aria-invalid:focus:ring-inset",
"focus:outline-hidden",
"disabled:cursor-not-allowed disabled:bg-control-bg disabled:opacity-50",
"read-only:cursor-default read-only:bg-control-bg read-only:focus:ring-0 read-only:focus:border-control-border"
diff --git a/frontend/src/components/ui/textarea.test.tsx b/frontend/src/components/ui/textarea.test.tsx
new file mode 100644
index 0000000000..3199111543
--- /dev/null
+++ b/frontend/src/components/ui/textarea.test.tsx
@@ -0,0 +1,38 @@
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, test } from "vitest";
+import { Textarea } from "./textarea";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+describe("Textarea", () => {
+ let container: HTMLDivElement;
+ let root: ReturnType<typeof createRoot>;
+
+ beforeEach(() => {
+ container = document.createElement("div");
+ document.body.appendChild(container);
+ root = createRoot(container);
+ });
+
+ afterEach(() => {
+ act(() => root.unmount());
+ container.remove();
+ });
+
+ test("uses an inset error focus ring when invalid", () => {
+ act(() => {
+ root.render(<Textarea aria-invalid="true" />);
+ });
+
+ const textarea = container.querySelector("textarea");
+ expect(textarea).not.toBeNull();
+ expect(textarea?.className).toContain("aria-invalid:border-error");
+ expect(textarea?.className).toContain("aria-invalid:focus:border-error");
+ expect(textarea?.className).toContain("aria-invalid:focus:ring-1");
+ expect(textarea?.className).toContain("aria-invalid:focus:ring-error/30");
+ expect(textarea?.className).toContain("aria-invalid:focus:ring-inset");
+ });
+});
diff --git a/frontend/src/components/ui/textarea.tsx b/frontend/src/components/ui/textarea.tsx
index ba6ac3cb2f..1e34d0fc15 100644
--- a/frontend/src/components/ui/textarea.tsx
+++ b/frontend/src/components/ui/textarea.tsx
@@ -8,7 +8,7 @@ const textareaVariants = cva(
cn(
"flex min-h-25 w-full rounded-xs border border-control-border bg-transparent text-main transition-colors",
"placeholder:text-control-placeholder",
- "aria-invalid:border-error",
+ "aria-invalid:border-error aria-invalid:focus:border-error aria-invalid:focus:ring-1 aria-invalid:focus:ring-error/30 aria-invalid:focus:ring-inset",
"focus:outline-hidden focus:ring-1 focus:ring-accent focus:border-accent",
"disabled:cursor-not-allowed disabled:bg-control-bg disabled:opacity-50"
)
diff --git a/frontend/src/routes/workspace/profile/EmailInput.test.tsx b/frontend/src/routes/workspace/profile/EmailInput.test.tsx
new file mode 100644
index 0000000000..f66425e77a
--- /dev/null
+++ b/frontend/src/routes/workspace/profile/EmailInput.test.tsx
@@ -0,0 +1,57 @@
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
+import { EmailInput } from "./EmailInput";
+
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+vi.mock("@/stores/app", () => ({
+ useAppStore: (selector: (state: object) => unknown) =>
+ selector({
+ getWorkspaceProfile: () => ({
+ domains: ["example.com"],
+ enforceIdentityDomain: false,
+ }),
+ }),
+}));
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+describe("EmailInput", () => {
+ let container: HTMLDivElement;
+ let root: ReturnType<typeof createRoot>;
+
+ beforeEach(() => {
+ container = document.createElement("div");
+ document.body.appendChild(container);
+ root = createRoot(container);
+ });
+
+ afterEach(() => {
+ act(() => root.unmount());
+ container.remove();
+ });
+
+ test.each([
+ { showDomain: false, value: "[email protected]" },
+ { showDomain: true, value: "[email protected]" },
+ ])("marks an invalid email with the shared error state", ({ showDomain, value }) => {
+ act(() => {
+ root.render(
+ <EmailInput
+ value={value}
+ showDomain={showDomain}
+ onChange={() => undefined}
+ />
+ );
+ });
+
+ expect(container.querySelector("input")?.getAttribute("aria-invalid")).toBe(
+ "true"
+ );
+ });
+});
diff --git a/frontend/src/routes/workspace/profile/EmailInput.tsx b/frontend/src/routes/workspace/profile/EmailInput.tsx
index c87b533910..2939bfc071 100644
--- a/frontend/src/routes/workspace/profile/EmailInput.tsx
+++ b/frontend/src/routes/workspace/profile/EmailInput.tsx
@@ -126,11 +126,8 @@ export function EmailInput({
value={localPart}
onChange={handleLocalPartChange}
disabled={disabled}
- className={
- hasEmailError
- ? "rounded-r-none border-error focus:ring-error"
- : "rounded-r-none"
- }
+ aria-invalid={hasEmailError || undefined}
+ className="rounded-r-none"
/>
<span className="flex items-center px-2 h-9 border-y border-control-border bg-control-bg text-sm text-control-light">
@
@@ -163,7 +160,7 @@ export function EmailInput({
value={fullValue}
onChange={handleFullChange}
disabled={disabled}
- className={hasEmailError ? "border-error focus:ring-error" : ""}
+ aria-invalid={hasEmailError || undefined}
/>
{hasEmailError && (
<span className="text-error text-sm mt-1">
diff --git a/frontend/src/routes/workspace/profile/UserPasswordSection.test.tsx b/frontend/src/routes/workspace/profile/UserPasswordSection.test.tsx
new file mode 100644
index 0000000000..dfb526f015
--- /dev/null
+++ b/frontend/src/routes/workspace/profile/UserPasswordSection.test.tsx
@@ -0,0 +1,46 @@
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
+import { UserPasswordSection } from "./UserPasswordSection";
+
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+describe("UserPasswordSection", () => {
+ let container: HTMLDivElement;
+ let root: ReturnType<typeof createRoot>;
+
+ beforeEach(() => {
+ container = document.createElement("div");
+ document.body.appendChild(container);
+ root = createRoot(container);
+ });
+
+ afterEach(() => {
+ act(() => root.unmount());
+ container.remove();
+ });
+
+ test("marks invalid password fields with the shared error state", () => {
+ act(() => {
+ root.render(
+ <UserPasswordSection
+ password="short"
+ passwordConfirm="different"
+ onPasswordChange={() => undefined}
+ onPasswordConfirmChange={() => undefined}
+ />
+ );
+ });
+
+ const inputs = container.querySelectorAll("input");
+ expect(inputs).toHaveLength(2);
+ expect(inputs[0]?.getAttribute("aria-invalid")).toBe("true");
+ expect(inputs[1]?.getAttribute("aria-invalid")).toBe("true");
+ });
+});
diff --git a/frontend/src/routes/workspace/profile/UserPasswordSection.tsx b/frontend/src/routes/workspace/profile/UserPasswordSection.tsx
index ec9e9b0617..ce51a5b2cb 100644
--- a/frontend/src/routes/workspace/profile/UserPasswordSection.tsx
+++ b/frontend/src/routes/workspace/profile/UserPasswordSection.tsx
@@ -172,7 +172,7 @@ export function UserPasswordSection({
autoComplete="new-password"
placeholder={t("common.sensitive-placeholder")}
disabled={disabled}
- className={passwordHint ? "border-error focus:ring-error" : ""}
+ aria-invalid={passwordHint || undefined}
onChange={(e) => onPasswordChange(e.target.value)}
/>
<Button
@@ -207,9 +207,7 @@ export function UserPasswordSection({
autoComplete="new-password"
placeholder={t("settings.profile.password-confirm-placeholder")}
disabled={disabled}
- className={
- passwordMismatch ? "border-error focus:ring-error" : ""
- }
+ aria-invalid={passwordMismatch || undefined}
onChange={(e) => onPasswordConfirmChange(e.target.value)}
/>
<Button