From 5c98bb6c0f313ce336dfa1ecbf0f0eada0137b35 Mon Sep 17 00:00:00 2001 From: Gildas Garcia <1122076+djhi@users.noreply.github.com> Date: Thu, 26 Mar 2026 16:24:08 +0100 Subject: [PATCH] chore: `react-hook-form` best practices (#44221) ## Problem The design system documentation and examples promote an invalid usage of react-hook-form state. ## Solution - Fix the documentation and examples - Update Claude skills for future components ## Out of scope - Fix current code across the repository --- .cursor/rules/studio/forms/RULE.md | 5 ++--- apps/design-system/content/docs/ui-patterns/forms.mdx | 2 +- apps/design-system/content/docs/ui-patterns/modality.mdx | 7 ++++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.cursor/rules/studio/forms/RULE.md b/.cursor/rules/studio/forms/RULE.md index b9b729111b5..74f8383f862 100644 --- a/.cursor/rules/studio/forms/RULE.md +++ b/.cursor/rules/studio/forms/RULE.md @@ -1,5 +1,5 @@ --- -description: "Studio: form patterns (page layouts + side panels) and react-hook-form conventions" +description: 'Studio: form patterns (page layouts + side panels) and react-hook-form conventions' globs: - apps/studio/**/*.{ts,tsx} alwaysApply: false @@ -29,7 +29,6 @@ Use the Design System UI pattern docs as the source of truth: ## Actions and state -- Handle dirty state (`form.formState.isDirty`) to show Cancel and to disable Save. +- Handle dirty state by destructuring `isDirty` from `formState` (`const { isDirty } = form.formState`) then use it to show Cancel and to disable Save. - Show loading on submit buttons via `loading`. - When submit button is outside the `