Skip to content

Commit

Permalink
Merge pull request #12712 from Snuffleupagus/issue-12704
Browse files Browse the repository at this point in the history
Attempt to handle collapsed outline items, in the default viewer, according to the specification (issue 12704, PR 10890 follow-up)
  • Loading branch information
timvandermeij authored Dec 9, 2020
2 parents f48cfba + 09f79ff commit 93b3ba2
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion web/pdf_outline_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,23 @@ class PDFOutlineViewer extends BaseTreeViewer {
* @private
*/
_addToggleButton(div, { count, items }) {
const hidden = count < 0 && Math.abs(count) === items.length;
let hidden = false;
if (count < 0) {
let totalCount = items.length;
if (totalCount > 0) {
const queue = [...items];
while (queue.length > 0) {
const { count: nestedCount, items: nestedItems } = queue.shift();
if (nestedCount > 0 && nestedItems.length > 0) {
totalCount += nestedItems.length;
queue.push(...nestedItems);
}
}
}
if (Math.abs(count) === totalCount) {
hidden = true;
}
}
super._addToggleButton(div, hidden);
}

Expand Down

0 comments on commit 93b3ba2

Please sign in to comment.