@adecore/ui 0.50.2 → 0.50.3

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.
@@ -80,9 +80,28 @@ export function CommandPaletteVirtualList({
80
80
  }
81
81
  const highlight = (index_0, reason) => {
82
82
  const row = itemRows[index_0];
83
- if (row !== undefined && reason !== 'pointer') {
84
- virtualizer.scrollToIndex(row, {
85
- align: reason === 'none' ? 'start' : 'auto'
83
+ if (row === undefined || reason === 'pointer') {
84
+ return;
85
+ }
86
+ // The first item of a group brings its label along, so the list never opens on half a label.
87
+ const label = row > 0 && rows[row - 1].index === -1 ? row - 1 : null;
88
+ if (reason === 'none') {
89
+ const target = label ?? row;
90
+ if (target === 0) {
91
+ virtualizer.scrollToOffset(0);
92
+ } else {
93
+ virtualizer.scrollToIndex(target, {
94
+ align: 'start'
95
+ });
96
+ }
97
+ return;
98
+ }
99
+ virtualizer.scrollToIndex(row, {
100
+ align: 'auto'
101
+ });
102
+ if (label !== null) {
103
+ virtualizer.scrollToIndex(label, {
104
+ align: 'auto'
86
105
  });
87
106
  }
88
107
  };
@@ -92,7 +111,7 @@ export function CommandPaletteVirtualList({
92
111
  scroll.current = null;
93
112
  }
94
113
  };
95
- }, [scroll, virtualizer, itemRows]);
114
+ }, [scroll, virtualizer, itemRows, rows]);
96
115
  const visible = virtualizer.getVirtualItems();
97
116
  const visibleGroups = new Map();
98
117
  for (const item of visible) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/ui",
3
- "version": "0.50.2",
3
+ "version": "0.50.3",
4
4
  "description": "React components, a theme, formatters and a settings dialog for desktop-grade apps on React 19, Base UI and Tailwind 4.",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "author": "Bas Milius",
@@ -90,8 +90,29 @@ export function CommandPaletteVirtualList<ItemValue, Group extends { items: read
90
90
  const highlight = (index: number, reason: string): void => {
91
91
  const row = itemRows[index];
92
92
 
93
- if (row !== undefined && reason !== 'pointer') {
94
- virtualizer.scrollToIndex(row, { align: reason === 'none' ? 'start' : 'auto' });
93
+ if (row === undefined || reason === 'pointer') {
94
+ return;
95
+ }
96
+
97
+ // The first item of a group brings its label along, so the list never opens on half a label.
98
+ const label = row > 0 && rows[row - 1]!.index === -1 ? row - 1 : null;
99
+
100
+ if (reason === 'none') {
101
+ const target = label ?? row;
102
+
103
+ if (target === 0) {
104
+ virtualizer.scrollToOffset(0);
105
+ } else {
106
+ virtualizer.scrollToIndex(target, { align: 'start' });
107
+ }
108
+
109
+ return;
110
+ }
111
+
112
+ virtualizer.scrollToIndex(row, { align: 'auto' });
113
+
114
+ if (label !== null) {
115
+ virtualizer.scrollToIndex(label, { align: 'auto' });
95
116
  }
96
117
  };
97
118
 
@@ -102,7 +123,7 @@ export function CommandPaletteVirtualList<ItemValue, Group extends { items: read
102
123
  scroll.current = null;
103
124
  }
104
125
  };
105
- }, [scroll, virtualizer, itemRows]);
126
+ }, [scroll, virtualizer, itemRows, rows]);
106
127
 
107
128
  const visible = virtualizer.getVirtualItems();
108
129
  const visibleGroups = new Map<number, typeof visible>();