fix: update collapseAll method

to avoid collapsing whole object/array
This commit is contained in:
Oleksiy Kachynskyy 2020-03-20 13:40:29 +02:00
parent afc7a95f13
commit 9d7249e4bc

View File

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