@conform-to/react 1.15.0 → 1.15.1

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/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  ╚══════╝ ╚═════╝ ╚═╝ ╚══╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
8
8
  ```
9
9
 
10
- Version 1.15.0 / License MIT / Copyright (c) 2025 Edmund Hung
10
+ Version 1.15.1 / License MIT / Copyright (c) 2025 Edmund Hung
11
11
 
12
12
  Progressively enhance HTML forms with React. Build resilient, type-safe forms with no hassle using web standards.
13
13
 
@@ -29,9 +29,18 @@ function initializeField(element, options) {
29
29
  }
30
30
  var defaultValue = typeof (options === null || options === void 0 ? void 0 : options.value) === 'string' || typeof (options === null || options === void 0 ? void 0 : options.defaultChecked) === 'boolean' ? options.defaultChecked ? (_options$value = options.value) !== null && _options$value !== void 0 ? _options$value : 'on' : null : options === null || options === void 0 ? void 0 : options.defaultValue;
31
31
 
32
- // Update the value of the element, including the default value
32
+ // Use change helper to set value and dispatch events
33
+ // This syncs React's internal value tracker so subsequent
34
+ // programmatic changes will properly trigger onChange
35
+ if (defaultValue !== undefined) {
36
+ future.change(element, defaultValue, {
37
+ // To avoid triggering validation on initialization
38
+ preventDefault: true
39
+ });
40
+ }
41
+
42
+ // Set the default value after change to preserve it for form reset
33
43
  future.updateField(element, {
34
- value: defaultValue,
35
44
  defaultValue
36
45
  });
37
46
  element.dataset.conform = 'initialized';
@@ -1,4 +1,4 @@
1
- import { updateField, isGlobalInstance, isFieldElement, requestIntent, getValueAtPath, change } from '@conform-to/dom/future';
1
+ import { change, updateField, isGlobalInstance, isFieldElement, requestIntent, getValueAtPath } from '@conform-to/dom/future';
2
2
  import { serializeIntent } from './intent.mjs';
3
3
 
4
4
  function getFormElement(formRef) {
@@ -25,9 +25,18 @@ function initializeField(element, options) {
25
25
  }
26
26
  var defaultValue = typeof (options === null || options === void 0 ? void 0 : options.value) === 'string' || typeof (options === null || options === void 0 ? void 0 : options.defaultChecked) === 'boolean' ? options.defaultChecked ? (_options$value = options.value) !== null && _options$value !== void 0 ? _options$value : 'on' : null : options === null || options === void 0 ? void 0 : options.defaultValue;
27
27
 
28
- // Update the value of the element, including the default value
28
+ // Use change helper to set value and dispatch events
29
+ // This syncs React's internal value tracker so subsequent
30
+ // programmatic changes will properly trigger onChange
31
+ if (defaultValue !== undefined) {
32
+ change(element, defaultValue, {
33
+ // To avoid triggering validation on initialization
34
+ preventDefault: true
35
+ });
36
+ }
37
+
38
+ // Set the default value after change to preserve it for form reset
29
39
  updateField(element, {
30
- value: defaultValue,
31
40
  defaultValue
32
41
  });
33
42
  element.dataset.conform = 'initialized';
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Conform view adapter for react",
4
4
  "homepage": "https://conform.guide",
5
5
  "license": "MIT",
6
- "version": "1.15.0",
6
+ "version": "1.15.1",
7
7
  "main": "./dist/index.js",
8
8
  "module": "./dist/index.mjs",
9
9
  "types": "./dist/index.d.ts",
@@ -41,7 +41,7 @@
41
41
  "url": "https://github.com/edmundhung/conform/issues"
42
42
  },
43
43
  "dependencies": {
44
- "@conform-to/dom": "1.15.0"
44
+ "@conform-to/dom": "1.15.1"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@babel/core": "^7.17.8",