@tunghtml/strapi-plugin-composite-field 1.2.7 → 1.2.8

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
@@ -141,6 +141,7 @@ Enable **Auto-generate** in Advanced settings to automatically update the compos
141
141
  - If you manually edit the composite field, it will preserve your changes
142
142
  - When any source field changes, auto-generation resumes with the new values
143
143
  - This prevents accidental overwrites while maintaining automatic updates
144
+ - Opening an existing entry keeps its saved value: the field is only regenerated after a source field changes, so the entry is not marked as modified on load
144
145
 
145
146
  ### Space-Only Separator
146
147
 
@@ -175,6 +176,13 @@ Result: Panel Discussion - John Doe
175
176
 
176
177
  ## Changelog
177
178
 
179
+ ### v1.2.8 (2026-10-19)
180
+
181
+ **🐛 Bug Fixes:**
182
+
183
+ - Opening an existing entry no longer regenerates the composite value, which marked the form as modified and rewrote the stored value on the next save
184
+ - Loading another entry or resetting the form takes the loaded value as the new starting point
185
+
178
186
  ### v1.2.4 (2026-02-05)
179
187
 
180
188
  **🎯 Improvements:**
@@ -28,10 +28,15 @@ const CompositeInput = (props) => {
28
28
  const [isManuallyEdited, setIsManuallyEdited] = React.useState(false);
29
29
 
30
30
  const lastGeneratedVal = React.useRef(value || '');
31
- const lastWatchedValues = React.useRef([]);
31
+ // Source values the field was last generated from; null until the form has loaded
32
+ const lastWatchedValues = React.useRef(null);
32
33
 
33
34
  React.useEffect(() => {
34
35
  const validValue = value || '';
36
+ // A value this field did not produce (another entry loaded, form reset) is a new baseline
37
+ if (validValue !== lastGeneratedVal.current) {
38
+ lastWatchedValues.current = null;
39
+ }
35
40
  setLocalValue(validValue);
36
41
  lastGeneratedVal.current = validValue;
37
42
  // Reset manual edit flag when value changes from outside (e.g., form reset)
@@ -177,13 +182,19 @@ const CompositeInput = (props) => {
177
182
 
178
183
  // Check if watched values actually changed
179
184
  const currentWatchedValues = JSON.stringify(watchedValues);
180
- const lastWatchedValuesStr = JSON.stringify(lastWatchedValues.current);
185
+
186
+ // Keep the saved value when an entry opens: regenerating it there marks the form as
187
+ // modified and overwrites values written by the server on the next save
188
+ if (lastWatchedValues.current === null) {
189
+ lastWatchedValues.current = currentWatchedValues;
190
+ return;
191
+ }
181
192
 
182
193
  // Only auto-generate if:
183
194
  // 1. Values actually changed
184
195
  // 2. User hasn't manually edited the field
185
- if (currentWatchedValues !== lastWatchedValuesStr) {
186
- lastWatchedValues.current = watchedValues;
196
+ if (currentWatchedValues !== lastWatchedValues.current) {
197
+ lastWatchedValues.current = currentWatchedValues;
187
198
 
188
199
  if (!isManuallyEdited) {
189
200
  const timeoutId = setTimeout(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tunghtml/strapi-plugin-composite-field",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "A Strapi v5 plugin to create composite display fields by combining multiple text, string, and enum fields with auto-generate support",
5
5
  "keywords": [
6
6
  "strapi",