nucleus-core-ts 0.9.839 → 0.9.841

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.
@@ -100,14 +100,42 @@ export function IntegrationsPage({ title = 'Integrations', subtitle = 'Connect a
100
100
  focusTargetEntity,
101
101
  focusStep
102
102
  ]);
103
+ /**
104
+ * Chosen for them ONCE, and never again.
105
+ *
106
+ * This used to re-choose whenever nothing was selected — so pressing "Change"
107
+ * cleared the connection and the same effect immediately put it back. There
108
+ * was no way to reach the list again short of reloading the page, and the
109
+ * button looked broken rather than overruled.
110
+ */ const autoSelected = useRef(false);
103
111
  const followFocus = useEffectEvent(()=>{
104
112
  if (!store.focusTargetEntity) return;
105
113
  if (!store.selectedSourceId) {
106
- if (store.sources.length === 1 && store.sources[0]) store.selectSource(store.sources[0].id);
114
+ if (!autoSelected.current && store.sources.length === 1 && store.sources[0]) {
115
+ autoSelected.current = true;
116
+ store.selectSource(store.sources[0].id);
117
+ }
107
118
  return;
108
119
  }
109
120
  if (store.tab !== 'mappings') store.setTab('mappings');
110
121
  });
122
+ /**
123
+ * Leaving a connection spends the arrival.
124
+ *
125
+ * Somebody who pressed "Change" is choosing a different connection; the table
126
+ * they arrived asking about is no longer what they are doing, and carrying it
127
+ * forward would jump them into a mapping of a connection they had not picked
128
+ * yet.
129
+ */ const forgetFocusOnLeave = useEffectEvent(()=>{
130
+ if (autoSelected.current && !store.selectedSourceId && store.focusTargetEntity) {
131
+ store.setFocusTargetEntity(null);
132
+ }
133
+ });
134
+ useEffect(()=>{
135
+ forgetFocusOnLeave();
136
+ }, [
137
+ store.selectedSourceId
138
+ ]);
111
139
  useEffect(()=>{
112
140
  followFocus();
113
141
  }, [