Skip to content

Commit 21590cc

Browse files
committed
fix bug
1 parent 7af33ed commit 21590cc

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

web_src/js/features/file-fold.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@ import {svg} from '../svg.js';
55
// The fold arrow is the icon displayed on the upper left of the file box, especially intended for components having the 'fold-file' class.
66
// The file content box is the box that should be hidden or shown, especially intended for components having the 'file-content' class.
77
//
8-
export function setFileFolding(fileContentBox, foldArrow, newFold) {
9-
foldArrow.innerHTML = svg(`octicon-chevron-${newFold ? 'right' : 'down'}`, 18);
10-
fileContentBox.setAttribute('data-folded', newFold);
11-
}
12-
13-
// Like `setFileFolding`, except that it automatically inverts the current file folding state.
14-
export function invertFileFolding(fileContentBox, foldArrow, isFromViewed = false) {
8+
export function setFileFolding(fileContentBox, foldArrow, newFold, isFromViewed = false) {
159
const diffFileHeader = fileContentBox.querySelector('.diff-file-header');
1610
const isFolded = fileContentBox.getAttribute('data-folded');
17-
setFileFolding(fileContentBox, foldArrow, isFolded !== 'true');
11+
console.log('newFold', newFold)
12+
foldArrow.innerHTML = svg(`octicon-chevron-${newFold ? 'right' : 'down'}`, 18);
13+
fileContentBox.setAttribute('data-folded', newFold);
1814
// scroll position needs to be adjusted only when folding the file
1915
// and scrollY is greater than current file header's offsetTop
2016
if (isFolded === 'false' && window.scrollY > diffFileHeader.offsetTop) {
@@ -31,3 +27,8 @@ export function invertFileFolding(fileContentBox, foldArrow, isFromViewed = fals
3127
});
3228
}
3329
}
30+
31+
// Like `setFileFolding`, except that it automatically inverts the current file folding state.
32+
export function invertFileFolding(fileContentBox, foldArrow) {
33+
setFileFolding(fileContentBox, foldArrow, fileContentBox.getAttribute('data-folded') !== 'true');
34+
}

web_src/js/features/pull-view-file.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {invertFileFolding} from './file-fold.js';
1+
import {setFileFolding} from './file-fold.js';
22

33
const {csrfToken, pageData} = window.config;
44
const prReview = pageData.prReview || {};
@@ -65,8 +65,7 @@ export function initViewedCheckboxListenerFor() {
6565

6666
// Fold the file accordingly
6767
const parentBox = form.closest('.diff-file-header');
68-
// Click on "viewed" inverted the file folding status
69-
invertFileFolding(parentBox.closest('.file-content'), parentBox.querySelector('.fold-file'), true);
68+
setFileFolding(parentBox.closest('.file-content'), parentBox.querySelector('.fold-file'), this.checked, true);
7069
});
7170
}
7271
}

0 commit comments

Comments
 (0)