diff --git a/.changeset/editor-keeps-content-on-rebuild.md b/.changeset/editor-keeps-content-on-rebuild.md new file mode 100644 index 00000000..25ba69f7 --- /dev/null +++ b/.changeset/editor-keeps-content-on-rebuild.md @@ -0,0 +1,5 @@ +--- +"@javaabu/onu": patch +--- + +`WysiwygEditor` and `BlockEditor` keep what was typed when `thaana` is toggled, instead of going back to `defaultValue`, and the placeholder switches language with the locale. diff --git a/.changeset/form-ref-cleanup.md b/.changeset/form-ref-cleanup.md new file mode 100644 index 00000000..d5548349 --- /dev/null +++ b/.changeset/form-ref-cleanup.md @@ -0,0 +1,5 @@ +--- +"@javaabu/onu": patch +--- + +`Form` attaches a forwarded ref once instead of on every render, and calls a React 19 ref cleanup on unmount. diff --git a/.changeset/listing-state-stable-on-value-change.md b/.changeset/listing-state-stable-on-value-change.md new file mode 100644 index 00000000..074fb133 --- /dev/null +++ b/.changeset/listing-state-stable-on-value-change.md @@ -0,0 +1,5 @@ +--- +"@javaabu/onu": patch +--- + +`useListingState` no longer calls `onValueChange` on every render when `paramNames` is passed inline, or on mount under StrictMode; it fires only when the listing state changes. diff --git a/.changeset/merged-ref-cleanup.md b/.changeset/merged-ref-cleanup.md new file mode 100644 index 00000000..5c7dbd53 --- /dev/null +++ b/.changeset/merged-ref-cleanup.md @@ -0,0 +1,5 @@ +--- +"@javaabu/onu": patch +--- + +Inputs that forward a ref now honour React 19 ref cleanup functions: a ref callback that returns a cleanup has it called on unmount instead of being called again with `null`. diff --git a/.changeset/signature-pad-keeps-drawing.md b/.changeset/signature-pad-keeps-drawing.md new file mode 100644 index 00000000..d2d57b62 --- /dev/null +++ b/.changeset/signature-pad-keeps-drawing.md @@ -0,0 +1,5 @@ +--- +"@javaabu/onu": patch +--- + +`SignaturePad` keeps the drawing when the language changes or `OnuProvider` re-renders with new props, so the pad and the submitted value no longer disagree. diff --git a/.changeset/validation-summary-ref-cleanup.md b/.changeset/validation-summary-ref-cleanup.md new file mode 100644 index 00000000..a1db931f --- /dev/null +++ b/.changeset/validation-summary-ref-cleanup.md @@ -0,0 +1,5 @@ +--- +"@javaabu/onu": patch +--- + +`ValidationSummary` attaches a forwarded ref once instead of on every render, and calls a React 19 ref cleanup on unmount. diff --git a/packages/onu/src/components/form/form.test.tsx b/packages/onu/src/components/form/form.test.tsx index a5702c09..c8fd41b9 100644 --- a/packages/onu/src/components/form/form.test.tsx +++ b/packages/onu/src/components/form/form.test.tsx @@ -251,6 +251,18 @@ describe("Form", () => { expect(screen.getByRole("alert")).toHaveTextContent("މި ފޯމުގައި 2 މައްސަލަ ވޭ") await expectNoA11yViolations() }) + + it("attaches a forwarded ref once and calls its React 19 cleanup (#66, 4.5)", () => { + const cleanup = vi.fn() + const ref = vi.fn(() => cleanup) + const { rerender, unmount, container } = renderWithOnu(
) + rerender() + expect(ref).toHaveBeenCalledTimes(1) + expect(ref).toHaveBeenCalledWith(container.querySelector("form")) + unmount() + expect(cleanup).toHaveBeenCalledTimes(1) + expect(ref).toHaveBeenCalledTimes(1) + }) }) describe("Form with react-hook-form", () => { diff --git a/packages/onu/src/components/form/form.tsx b/packages/onu/src/components/form/form.tsx index a6c01c25..f8897cc3 100644 --- a/packages/onu/src/components/form/form.tsx +++ b/packages/onu/src/components/form/form.tsx @@ -3,6 +3,7 @@ import * as React from "react" import { FormProvider, type FieldValues, type UseFormReturn } from "react-hook-form" +import { useMergedRef } from "../../hooks/use-merged-ref" import { cn } from "../../lib/utils" import type { LabelLayout } from "../../providers/onu-provider" import { useTranslation } from "../../providers/onu-provider" @@ -127,6 +128,7 @@ export function Form