diff --git a/src/components/JsonViewer/JsonViewer.tsx b/src/components/JsonViewer/JsonViewer.tsx index bf735299..95f4ce94 100644 --- a/src/components/JsonViewer/JsonViewer.tsx +++ b/src/components/JsonViewer/JsonViewer.tsx @@ -57,11 +57,10 @@ class Json extends React.PureComponent { collapseAll = () => { const elements = this.node.getElementsByClassName('collapsible'); - for (const expanded of Array.prototype.slice.call(elements)) { - // const collapsed = elements[i]; - if ((expanded.parentNode as Element)!.classList.contains('redoc-json')) { - continue; - } + // skip first item to avoid collapsing whole object/array + const elementsArr = Array.prototype.slice.call(elements).slice(1); + + for (const expanded of elementsArr) { (expanded.parentNode as Element)!.classList.add('collapsed'); } };