|
143 | 143 | parent,
|
144 | 144 | order: result.length,
|
145 | 145 | selected: () => selectedIds.has(node.id),
|
146 |
| - expanded: () => expandedIds.has(node.id), |
| 146 | + expanded: () => { |
| 147 | + if (parent !== undefined && !parent.expanded) { |
| 148 | + return false; |
| 149 | + } |
| 150 | + return expandedIds.has(node.id); |
| 151 | + }, |
147 | 152 | inClipboard: () => clipboardIds.has(node.id),
|
148 | 153 | disabled: () => parent?.disabled || isItemDisabled(node),
|
149 | 154 | visible: () => {
|
150 |
| - if (parent !== undefined && (!parent.expanded || !parent.visible)) { |
| 155 | + if (parent !== undefined && !parent.expanded) { |
151 | 156 | return false;
|
152 | 157 | }
|
153 | 158 | return !isItemHidden(node);
|
|
210 | 215 | }
|
211 | 216 |
|
212 | 217 | while (current !== undefined && !current.visible) {
|
213 |
| - if (current.node.type === "folder") { |
| 218 | + if (current.node.type === "folder" && !current.expanded) { |
214 | 219 | current = items[current.order + current.node.count + 1];
|
215 | 220 | } else {
|
216 | 221 | current = items[current.order + 1];
|
|
231 | 236 | function getFirstVisibleItem() {
|
232 | 237 | let current = items[0];
|
233 | 238 | if (current !== undefined && !current.visible) {
|
234 |
| - current = getNextVisibleItem(current, { skipChildren: true }); |
| 239 | + current = getNextVisibleItem(current); |
235 | 240 | }
|
236 | 241 | return current;
|
237 | 242 | }
|
238 | 243 |
|
239 | 244 | function getLastVisibleItem() {
|
240 | 245 | let current = items[items.length - 1];
|
241 | 246 | if (current !== undefined && !current.visible) {
|
242 |
| - while (current.parent !== undefined && !current.parent.visible) { |
| 247 | + while (current.parent !== undefined && !current.parent.expanded) { |
243 | 248 | current = current.parent;
|
244 | 249 | }
|
245 | 250 | current = getPreviousVisibleItem(current);
|
|
0 commit comments