Skip to content

Commit 5df2f9c

Browse files
marinaaisaDobromir Hristov
andauthored
Opt-Click on framework name expand/collapse everything (#428)
closes rdar://94150776 Co-authored-by: Dobromir Hristov <[email protected]>
1 parent 3eb58b7 commit 5df2f9c

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

src/components/Navigator/NavigatorCard.vue

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323
>
2424
<SidenavIcon class="icon-inline close-icon" />
2525
</button>
26-
<Reference :url="technologyPath" class="navigator-head" :id="INDEX_ROOT_KEY">
26+
<Reference
27+
class="navigator-head"
28+
:url="technologyPath"
29+
:id="INDEX_ROOT_KEY"
30+
@click.alt.native.prevent="toggleAllNodes"
31+
>
2732
<h2 class="card-link">
2833
{{ technology }}
2934
</h2>
@@ -281,6 +286,7 @@ export default {
281286
NO_CHILDREN,
282287
ERROR_FETCHING,
283288
ITEMS_FOUND,
289+
allNodesToggled: false,
284290
};
285291
},
286292
computed: {
@@ -506,6 +512,20 @@ export default {
506512
},
507513
},
508514
methods: {
515+
toggleAllNodes() {
516+
const parentNodes = this.children.filter(child => child.parent === INDEX_ROOT_KEY
517+
&& child.type !== TopicTypes.groupMarker && child.childUIDs.length);
518+
// make sure all nodes get either open or close
519+
this.allNodesToggled = !this.allNodesToggled;
520+
if (this.allNodesToggled) {
521+
this.openNodes = {};
522+
this.generateNodesToRender();
523+
}
524+
525+
parentNodes.forEach((node) => {
526+
this.toggleFullTree(node);
527+
});
528+
},
509529
clearFilters() {
510530
this.filter = '';
511531
this.debouncedFilter = '';

tests/unit/components/Navigator/NavigatorCard.spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,30 @@ describe('NavigatorCard', () => {
364364
expect(wrapper.vm.focusedIndex).toBe(wrapper.findAll(NavigatorCardItem).length - 1);
365365
});
366366

367+
it('allows expand/collapse all symbols when clicking on framework name + while pressing alt', async () => {
368+
const wrapper = createWrapper();
369+
await flushPromises();
370+
// assert initial items are rendered
371+
expect(wrapper.findAll(NavigatorCardItem)).toHaveLength(4);
372+
373+
const navHead = wrapper.find('.navigator-head');
374+
375+
// open all children symbols
376+
navHead.trigger('click', { altKey: true });
377+
await wrapper.vm.$nextTick();
378+
expect(wrapper.findAll(NavigatorCardItem)).toHaveLength(children.length);
379+
380+
// close all children symbols
381+
navHead.trigger('click', { altKey: true });
382+
await wrapper.vm.$nextTick();
383+
expect(wrapper.findAll(NavigatorCardItem)).toHaveLength(2);
384+
385+
// open all children symbols
386+
navHead.trigger('click', { altKey: true });
387+
await wrapper.vm.$nextTick();
388+
expect(wrapper.findAll(NavigatorCardItem)).toHaveLength(children.length);
389+
});
390+
367391
it('allows the user to navigate to the first item on the list when pressing alt + up key', async () => {
368392
const wrapper = createWrapper();
369393
await flushPromises();

0 commit comments

Comments
 (0)