@headless-tree/core 0.0.0-20260107220200 → 0.0.0-20260107224057

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/CHANGELOG.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # @headless-tree/core
2
2
 
3
- ## 0.0.0-20260107220200
3
+ ## 0.0.0-20260107224057
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - 39a8b44: Add skipUpdateTree parameter to `updateCachedChildrenIds` and `updateCachedData` in async tree loader
8
+ - 26ecc1b: Fixed an issue where dropping items inside a collapsed folder will make the tree become un-focusable until a new item is clicked with mouse again. This could break usage with keyboard-only drag operations.
9
+ - 0108b7a: Fixed a bug where some hotkeys (like up/down navigation, search and renaming) doesn't work after items are dragged within the tree (#179)
8
10
  - ffd2619: Fixed an issue where `canDropForeignDragObject` was being called in `onDragOver` events without payload. `canDropForeignDragObject` should never be called in `onDragOver` events since there, browsers do not allow access to the data transfer payload. Now, `canDropForeignDragObject` is only called in onDrop events, and `canDragForeignDragObjectOver` is always called in `onDragOver` events.
9
11
 
10
12
  ## 1.6.1
package/dist/index.js CHANGED
@@ -125,6 +125,7 @@ var poll = (fn, interval = 100, timeout = 1e3) => new Promise((resolve) => {
125
125
  }, interval);
126
126
  clear = setTimeout(() => {
127
127
  clearInterval(i);
128
+ resolve();
128
129
  }, timeout);
129
130
  });
130
131
 
@@ -214,12 +215,16 @@ var treeFeature = {
214
215
  },
215
216
  updateDomFocus: ({ tree }) => {
216
217
  setTimeout(() => __async(null, null, function* () {
217
- var _a, _b;
218
+ var _a, _b, _c, _d, _e;
218
219
  const focusedItem = tree.getFocusedItem();
219
220
  (_b = (_a = tree.getConfig()).scrollToItem) == null ? void 0 : _b.call(_a, focusedItem);
220
- yield poll(() => focusedItem.getElement() !== null, 20);
221
+ yield poll(() => focusedItem.getElement() !== null, 20, 500);
221
222
  const focusedElement = focusedItem.getElement();
222
- if (!focusedElement) return;
223
+ if (!focusedElement) {
224
+ (_c = tree.getItems()[0]) == null ? void 0 : _c.setFocused();
225
+ (_e = (_d = tree.getItems()[0]) == null ? void 0 : _d.getElement()) == null ? void 0 : _e.focus();
226
+ return;
227
+ }
223
228
  focusedElement.focus();
224
229
  }));
225
230
  },
@@ -1721,9 +1726,12 @@ var dragAndDropFeature = {
1721
1726
  dataRef.current.lastDragCode = void 0;
1722
1727
  if (draggedItems) {
1723
1728
  yield (_b = config.onDrop) == null ? void 0 : _b.call(config, draggedItems, target);
1729
+ draggedItems[0].setFocused();
1724
1730
  } else if (e.dataTransfer) {
1725
1731
  yield (_c = config.onDropForeignDragObject) == null ? void 0 : _c.call(config, e.dataTransfer, target);
1726
1732
  }
1733
+ tree.applySubStateUpdate("dnd", null);
1734
+ tree.updateDomFocus();
1727
1735
  })
1728
1736
  }),
1729
1737
  isDragTarget: ({ tree, item }) => {
@@ -1949,6 +1957,7 @@ var keyboardDragAndDropFeature = {
1949
1957
  } else if (dataTransfer) {
1950
1958
  yield (_d = config.onDropForeignDragObject) == null ? void 0 : _d.call(config, dataTransfer, target);
1951
1959
  }
1960
+ tree.updateDomFocus();
1952
1961
  tree.applySubStateUpdate(
1953
1962
  "assistiveDndState",
1954
1963
  3 /* Completed */
package/dist/index.mjs CHANGED
@@ -81,6 +81,7 @@ var poll = (fn, interval = 100, timeout = 1e3) => new Promise((resolve) => {
81
81
  }, interval);
82
82
  clear = setTimeout(() => {
83
83
  clearInterval(i);
84
+ resolve();
84
85
  }, timeout);
85
86
  });
86
87
 
@@ -170,12 +171,16 @@ var treeFeature = {
170
171
  },
171
172
  updateDomFocus: ({ tree }) => {
172
173
  setTimeout(() => __async(null, null, function* () {
173
- var _a, _b;
174
+ var _a, _b, _c, _d, _e;
174
175
  const focusedItem = tree.getFocusedItem();
175
176
  (_b = (_a = tree.getConfig()).scrollToItem) == null ? void 0 : _b.call(_a, focusedItem);
176
- yield poll(() => focusedItem.getElement() !== null, 20);
177
+ yield poll(() => focusedItem.getElement() !== null, 20, 500);
177
178
  const focusedElement = focusedItem.getElement();
178
- if (!focusedElement) return;
179
+ if (!focusedElement) {
180
+ (_c = tree.getItems()[0]) == null ? void 0 : _c.setFocused();
181
+ (_e = (_d = tree.getItems()[0]) == null ? void 0 : _d.getElement()) == null ? void 0 : _e.focus();
182
+ return;
183
+ }
179
184
  focusedElement.focus();
180
185
  }));
181
186
  },
@@ -1677,9 +1682,12 @@ var dragAndDropFeature = {
1677
1682
  dataRef.current.lastDragCode = void 0;
1678
1683
  if (draggedItems) {
1679
1684
  yield (_b = config.onDrop) == null ? void 0 : _b.call(config, draggedItems, target);
1685
+ draggedItems[0].setFocused();
1680
1686
  } else if (e.dataTransfer) {
1681
1687
  yield (_c = config.onDropForeignDragObject) == null ? void 0 : _c.call(config, e.dataTransfer, target);
1682
1688
  }
1689
+ tree.applySubStateUpdate("dnd", null);
1690
+ tree.updateDomFocus();
1683
1691
  })
1684
1692
  }),
1685
1693
  isDragTarget: ({ tree, item }) => {
@@ -1905,6 +1913,7 @@ var keyboardDragAndDropFeature = {
1905
1913
  } else if (dataTransfer) {
1906
1914
  yield (_d = config.onDropForeignDragObject) == null ? void 0 : _d.call(config, dataTransfer, target);
1907
1915
  }
1916
+ tree.updateDomFocus();
1908
1917
  tree.applySubStateUpdate(
1909
1918
  "assistiveDndState",
1910
1919
  3 /* Completed */
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "checkbox",
14
14
  "hook"
15
15
  ],
16
- "version": "0.0.0-20260107220200",
16
+ "version": "0.0.0-20260107224057",
17
17
  "main": "dist/index.d.ts",
18
18
  "module": "dist/index.mjs",
19
19
  "types": "dist/index.d.mts",
@@ -322,9 +322,13 @@ export const dragAndDropFeature: FeatureImplementation = {
322
322
 
323
323
  if (draggedItems) {
324
324
  await config.onDrop?.(draggedItems, target);
325
+ draggedItems[0].setFocused();
325
326
  } else if (e.dataTransfer) {
326
327
  await config.onDropForeignDragObject?.(e.dataTransfer, target);
327
328
  }
329
+
330
+ tree.applySubStateUpdate("dnd", null);
331
+ tree.updateDomFocus();
328
332
  },
329
333
  }),
330
334
 
@@ -254,6 +254,7 @@ export const keyboardDragAndDropFeature: FeatureImplementation = {
254
254
  await config.onDropForeignDragObject?.(dataTransfer, target);
255
255
  }
256
256
 
257
+ tree.updateDomFocus();
257
258
  tree.applySubStateUpdate(
258
259
  "assistiveDndState",
259
260
  AssistiveDndState.Completed,
@@ -107,9 +107,13 @@ export const treeFeature: FeatureImplementation<any> = {
107
107
  setTimeout(async () => {
108
108
  const focusedItem = tree.getFocusedItem();
109
109
  tree.getConfig().scrollToItem?.(focusedItem);
110
- await poll(() => focusedItem.getElement() !== null, 20);
110
+ await poll(() => focusedItem.getElement() !== null, 20, 500);
111
111
  const focusedElement = focusedItem.getElement();
112
- if (!focusedElement) return;
112
+ if (!focusedElement) {
113
+ tree.getItems()[0]?.setFocused();
114
+ tree.getItems()[0]?.getElement()?.focus();
115
+ return;
116
+ }
113
117
  focusedElement.focus();
114
118
  });
115
119
  },
package/src/utils.ts CHANGED
@@ -64,5 +64,6 @@ export const poll = (fn: () => boolean, interval = 100, timeout = 1000) =>
64
64
  }, interval);
65
65
  clear = setTimeout(() => {
66
66
  clearInterval(i);
67
+ resolve();
67
68
  }, timeout);
68
69
  });