@rachelallyson/hero-hook-form 2.8.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [2.9.0] - 2026-01-22
6
+
7
+ ### Added
8
+
9
+ - **Documentation: Memory-Safe Forms Guide**: Comprehensive guide for preventing Cypress memory leaks
10
+ - Complete migration guide from problematic to memory-safe conditional field arrays
11
+ - Working code examples and best practices
12
+ - Troubleshooting section for memory issues
13
+ - Performance optimization recommendations
14
+
15
+ - **Examples: Question Form Demo**: Working demonstration of memory-safe conditional field arrays
16
+ - Interactive example showing MULTIPLE_CHOICE question types
17
+ - Before/after code comparisons
18
+ - Real-world implementation patterns
19
+ - Cypress e2e test coverage
20
+
21
+ - **Enhanced Testing**: Additional test coverage and refinements
22
+ - Question form e2e tests demonstrating memory safety
23
+ - Updated Cypress test patterns for memory optimization
24
+ - Comprehensive validation of conditional field array behavior
25
+
26
+ ### Fixed
27
+
28
+ - **Test File Naming**: Corrected Cypress test file extensions (`.cy.ts` vs `.spec.ts`)
29
+ - **Conditional Rendering**: Improved formatting and error handling in conditional field components
30
+
5
31
  ## [2.8.0] - 2026-01-22
6
32
 
7
33
  ### Added
package/dist/index.js CHANGED
@@ -400,22 +400,30 @@ function ConditionalField({
400
400
  const form = useFormContext();
401
401
  const formValues = useWatch({ control });
402
402
  const shouldShow = condition(formValues);
403
- if (!shouldShow) {
403
+ const isAlwaysRegisteredFieldArray = field2 && typeof field2 === "object" && "type" in field2 && field2.type === "fieldArray" && "alwaysRegistered" in field2 && field2.alwaysRegistered === true;
404
+ if (!shouldShow && !isAlwaysRegisteredFieldArray) {
404
405
  return null;
405
406
  }
406
- return /* @__PURE__ */ React5.createElement("div", { className }, /* @__PURE__ */ React5.createElement(
407
- FormField,
407
+ return /* @__PURE__ */ React5.createElement(
408
+ "div",
408
409
  {
409
- config: field2,
410
- form,
411
- submissionState: {
412
- error: void 0,
413
- isSubmitted: false,
414
- isSubmitting: false,
415
- isSuccess: false
410
+ className,
411
+ style: !shouldShow && isAlwaysRegisteredFieldArray ? { display: "none" } : void 0
412
+ },
413
+ /* @__PURE__ */ React5.createElement(
414
+ FormField,
415
+ {
416
+ config: field2,
417
+ form,
418
+ submissionState: {
419
+ error: void 0,
420
+ isSubmitted: false,
421
+ isSubmitting: false,
422
+ isSuccess: false
423
+ }
416
424
  }
417
- }
418
- ));
425
+ )
426
+ );
419
427
  }
420
428
 
421
429
  // src/fields/ContentField.tsx
@@ -1363,8 +1371,13 @@ function FormFieldComponent({
1363
1371
  );
1364
1372
  }
1365
1373
  }
1374
+ let shouldRenderConditionalField = true;
1366
1375
  if ("condition" in fieldConfig && fieldConfig.condition && !fieldConfig.condition(watchedValues)) {
1367
- return null;
1376
+ if ("field" in fieldConfig && fieldConfig.field && typeof fieldConfig.field === "object" && "type" in fieldConfig.field && fieldConfig.field.type === "fieldArray" && "alwaysRegistered" in fieldConfig.field && fieldConfig.field.alwaysRegistered === true) {
1377
+ shouldRenderConditionalField = true;
1378
+ } else {
1379
+ return null;
1380
+ }
1368
1381
  }
1369
1382
  if ("dependsOn" in fieldConfig && fieldConfig.dependsOn) {
1370
1383
  const dependentValue = get(watchedValues, fieldConfig.dependsOn);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rachelallyson/hero-hook-form",
3
- "version": "2.8.0",
3
+ "version": "2.9.0",
4
4
  "description": "Typed form helpers that combine React Hook Form and HeroUI components.",
5
5
  "author": "Rachel Higley",
6
6
  "homepage": "https://rachelallyson.github.io/hero-hook-form/",