labellife-design-tool 2.2.3 → 2.2.4

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.
@@ -2101,6 +2101,32 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2101
2101
  }
2102
2102
  }, [fields.length]);
2103
2103
  var totalCount = initialTotalRef.current || fields.length;
2104
+
2105
+ // Back-from-summary: triggered by parent incrementing backTrigger prop
2106
+ // Must be defined and its useEffect called BEFORE any early returns (Rules of Hooks)
2107
+ var handleBackFromSummary = function handleBackFromSummary() {
2108
+ var last = completedHistoryRef.current.pop();
2109
+ if (!last) return;
2110
+ var el = last.el,
2111
+ previousValue = last.previousValue;
2112
+ if (el) {
2113
+ var isImage = el.custom && el.custom.inputType === 'image';
2114
+ el.set(isImage ? {
2115
+ src: previousValue || ''
2116
+ } : {
2117
+ text: previousValue || ''
2118
+ });
2119
+ isGoingBackRef.current = true;
2120
+ store._unresolveInputField(el);
2121
+ }
2122
+ // displayIndex stays unchanged — it already points to the last step (N-1)
2123
+ };
2124
+ react.useEffect(function () {
2125
+ if (backTrigger !== prevBackTriggerRef.current) {
2126
+ prevBackTriggerRef.current = backTrigger;
2127
+ handleBackFromSummary();
2128
+ }
2129
+ }, [backTrigger]);
2104
2130
  if (!enabled || fields.length === 0) return null;
2105
2131
 
2106
2132
  // Always show the first remaining field — the array shrinks as fields are resolved
@@ -2176,31 +2202,6 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2176
2202
  };
2177
2203
  var canGoBack = displayIndex > 0;
2178
2204
 
2179
- // Back-from-summary: triggered by parent incrementing backTrigger prop
2180
- var handleBackFromSummary = function handleBackFromSummary() {
2181
- var last = completedHistoryRef.current.pop();
2182
- if (!last) return;
2183
- var el = last.el,
2184
- previousValue = last.previousValue;
2185
- if (el) {
2186
- var isImage = el.custom && el.custom.inputType === 'image';
2187
- el.set(isImage ? {
2188
- src: previousValue || ''
2189
- } : {
2190
- text: previousValue || ''
2191
- });
2192
- isGoingBackRef.current = true;
2193
- store._unresolveInputField(el);
2194
- }
2195
- // displayIndex stays unchanged — it already points to the last step (N-1)
2196
- };
2197
- react.useEffect(function () {
2198
- if (backTrigger !== prevBackTriggerRef.current) {
2199
- prevBackTriggerRef.current = backTrigger;
2200
- handleBackFromSummary();
2201
- }
2202
- }, [backTrigger]);
2203
-
2204
2205
  // ── Resolve which dialog component to use ───────────────────────────
2205
2206
  // Priority: per-type custom dialog > global CustomDialog > built-in
2206
2207
  var TYPE_DIALOG_MAP = {