@topconsultnpm/sdkui-react 6.22.0-dev3.6 → 6.22.0-dev3.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.
@@ -147,15 +147,26 @@ const TMTreeView = ({ dataSource = [], focusedItem, selectedItems = [], allowMul
147
147
  return [];
148
148
  return flattenTreeWithDepth(dataSource);
149
149
  }, [enableVirtualization, dataSource, flattenTreeWithDepth]);
150
+ // Chiave dell'ultimo elemento verso cui si è effettivamente scrollato.
151
+ // Evita di ripetere lo scroll quando cambia solo la struttura dell'albero
152
+ // (es. espansione di un nodo) a parità di elemento focalizzato.
153
+ const lastScrolledKeyRef = useRef(undefined);
150
154
  // Scroll verso l'elemento focalizzato quando cambia (navigazione con frecce)
151
155
  useEffect(() => {
152
- if (!focusedItem?.key)
156
+ if (!focusedItem?.key) {
157
+ lastScrolledKeyRef.current = undefined;
158
+ return;
159
+ }
160
+ // Focus invariato: l'effect è stato rieseguito solo perché l'albero è cambiato
161
+ // (espansione/collasso di un nodo). La posizione di scroll non va toccata.
162
+ if (lastScrolledKeyRef.current === focusedItem.key)
153
163
  return;
154
164
  if (enableVirtualization) {
155
165
  // Lista virtualizzata: usa scrollToRow per garantire che l'elemento sia visibile
156
166
  const index = flattenedItems.findIndex(item => item.node.key === focusedItem.key);
157
167
  if (index >= 0 && listRef.current) {
158
168
  listRef.current.scrollToRow({ index, align: 'smart' });
169
+ lastScrolledKeyRef.current = focusedItem.key;
159
170
  }
160
171
  }
161
172
  else {
@@ -164,6 +175,7 @@ const TMTreeView = ({ dataSource = [], focusedItem, selectedItems = [], allowMul
164
175
  const element = containerRef.current.querySelector(`[data-node-key="${focusedItem.key}"]`);
165
176
  if (element) {
166
177
  element.scrollIntoView({ block: 'nearest', inline: 'nearest' });
178
+ lastScrolledKeyRef.current = focusedItem.key;
167
179
  }
168
180
  }
169
181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.22.0-dev3.6",
3
+ "version": "6.22.0-dev3.8",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",