Skip to content

Commit 218b5d8

Browse files
committed
fixed collapse for root node
1 parent 6703afa commit 218b5d8

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/app/components/StateRoute/ComponentMap/ComponentMap.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ export default function ComponentMap({
410410
<circle
411411
className='compMapRoot'
412412
r={25}
413-
fill="url('#root-gradient')"
414413
onClick={() => {
415414
dispatch(toggleExpanded(node.data));
416415
hideTooltip();

src/app/slices/mainSlice.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,16 @@ export const mainSlice = createSlice({
201201
tabs[currentTab].viewIndex = viewIndex === action.payload ? -1 : action.payload;
202202
},
203203

204-
changeSlider: (state, action) => { //should really be called jump to snapshot
204+
changeSlider: (state, action) => {
205+
//should really be called jump to snapshot
205206
const { port, currentTab, tabs } = state;
206207
const { hierarchy, snapshots } = tabs[currentTab] || {};
207208

208209
// finds the name by the action.payload parsing through the hierarchy to send to background.js the current name in the jump action
209210
const nameFromIndex = findName(action.payload, hierarchy);
210211
// nameFromIndex is a number based on which jump button is pushed
211212

212-
console.log("changeSlider to ", action.payload);
213+
console.log('changeSlider to ', action.payload);
213214

214215
port.postMessage({
215216
action: 'jumpToSnap',
@@ -451,7 +452,15 @@ export const mainSlice = createSlice({
451452

452453
toggleExpanded: (state, action) => {
453454
const { tabs, currentTab } = state;
454-
// find correct node from currLocation and toggle isExpanded
455+
const snapshot = tabs[currentTab].currLocation.stateSnapshot;
456+
457+
// Special case for root node
458+
if (action.payload.name === 'root' && snapshot.name === 'root') {
459+
snapshot.isExpanded = !snapshot.isExpanded;
460+
return;
461+
}
462+
463+
// Regular case for other nodes
455464
const checkChildren = (node) => {
456465
if (_.isEqual(node, action.payload)) {
457466
node.isExpanded = !node.isExpanded;
@@ -461,7 +470,7 @@ export const mainSlice = createSlice({
461470
});
462471
}
463472
};
464-
checkChildren(tabs[currentTab].currLocation.stateSnapshot);
473+
checkChildren(snapshot);
465474
},
466475

467476
deleteSeries: (state) => {

0 commit comments

Comments
 (0)