@vectoriox/iox-builder 4.18.0 → 4.18.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.
@@ -2751,6 +2751,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.31", ngImpo
2751
2751
  * meant only the toolbar could ever drive it. The toolbar's own switcher UI broke the header
2752
2752
  * (`.form-state-bar` had no CSS rule — see forms-and-inputs-plan.md Part 2) and was, separately,
2753
2753
  * the wrong home per board 3: the switcher belongs to the Form, not to global chrome.
2754
+ *
2755
+ * `setTarget` takes the real node, not just its id, and keeps it (privately) for `setState` to
2756
+ * use — `OverlayService.getNodeRef` matches by REFERENCE, not id (a repeater clone shares its
2757
+ * template's id), so a caller re-deriving "the current form" from an id alone could resolve the
2758
+ * wrong instance. Every consumer of this service only ever needs the id for display; the node
2759
+ * itself is this service's own business.
2754
2760
  */
2755
2761
  class FormStateService {
2756
2762
  constructor(_overlay) {
@@ -2760,28 +2766,33 @@ class FormStateService {
2760
2766
  state: FormRenderState.Idle,
2761
2767
  });
2762
2768
  this.state$ = this._state$.asObservable();
2769
+ this._targetNode = null;
2763
2770
  }
2764
2771
  getSnapshot() {
2765
2772
  return this._state$.value;
2766
2773
  }
2767
2774
  /** Called whenever the selection changes. A different form (or none) resets to Idle — a
2768
2775
  * visitor never lands on a form already showing someone else's Sent/Failed block. */
2769
- setTarget(formId) {
2770
- const current = this._state$.value;
2771
- if (current.formId === formId)
2776
+ setTarget(form) {
2777
+ const formId = form?.id ?? null;
2778
+ if (this._state$.value.formId === formId)
2772
2779
  return;
2780
+ this._targetNode = form;
2773
2781
  this._state$.next({ formId, state: FormRenderState.Idle });
2774
2782
  }
2775
2783
  /**
2776
- * Writes the state straight onto the live component instance — a VIEW state, never page
2777
- * data, so it must never be persisted (a saved page must not ship showing its own success
2778
- * message). Two input names on purpose: the canvas renders the container twin (`formState`)
2779
- * while the engine renders `IoxFormComponent` (`renderState`); `safeSetInput` drops whichever
2780
- * the rendered component doesn't declare, so this works on either path unbranched.
2784
+ * Writes the state straight onto the live component instance for the CURRENT target (set via
2785
+ * `setTarget`) — a VIEW state, never page data, so it must never be persisted (a saved page
2786
+ * must not ship showing its own success message). Two input names on purpose: the canvas
2787
+ * renders the container twin (`formState`) while the engine renders `IoxFormComponent`
2788
+ * (`renderState`); `safeSetInput` drops whichever the rendered component doesn't declare, so
2789
+ * this works on either path unbranched. A no-op when nothing is in scope.
2781
2790
  */
2782
- setState(form, state) {
2783
- this._state$.next({ formId: form.id ?? null, state });
2784
- const ref = this._overlay.getNodeRef(form)?.componentRef;
2791
+ setState(state) {
2792
+ if (!this._targetNode)
2793
+ return;
2794
+ this._state$.next({ formId: this._targetNode.id ?? null, state });
2795
+ const ref = this._overlay.getNodeRef(this._targetNode)?.componentRef;
2785
2796
  if (ref) {
2786
2797
  safeSetInput(ref, 'formState', state);
2787
2798
  safeSetInput(ref, 'renderState', state);
@@ -5971,7 +5982,7 @@ class BuilderComponent {
5971
5982
  }
5972
5983
  set selectedPath(path) {
5973
5984
  this._selectedPath = path;
5974
- this.formStateService.setTarget(nearestFormNode(path)?.id ?? null);
5985
+ this.formStateService.setTarget(nearestFormNode(path));
5975
5986
  }
5976
5987
  // Type-safe event forwarding for toolbar outputs
5977
5988
  handleToolbarModeChange(mode) {