Skip to content

Commit 830371b

Browse files
author
Oleksiy Kachynskyy
authored
fix: do not collapse top level on Collapse All in json samples (#1209)
* fix: update collapseAll method to avoid collapsing whole object/array * fix: remove extra "slice()" call
1 parent c6eaa02 commit 830371b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/components/JsonViewer/JsonViewer.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ class Json extends React.PureComponent<JsonProps> {
5757

5858
collapseAll = () => {
5959
const elements = this.node.getElementsByClassName('collapsible');
60-
for (const expanded of Array.prototype.slice.call(elements)) {
61-
// const collapsed = elements[i];
62-
if ((expanded.parentNode as Element)!.classList.contains('redoc-json')) {
63-
continue;
64-
}
60+
// skip first item to avoid collapsing whole object/array
61+
const elementsArr = Array.prototype.slice.call(elements, 1);
62+
63+
for (const expanded of elementsArr) {
6564
(expanded.parentNode as Element)!.classList.add('collapsed');
6665
}
6766
};

0 commit comments

Comments
 (0)