1
Fork 0

Fix: Uncollapse all comments when the target is invisible (fixes #8).

This commit is contained in:
Bauke 2020-01-12 22:17:45 +01:00
parent ad74b77fd8
commit 26cd9e3a13
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 9 additions and 2 deletions

View File

@ -27,8 +27,15 @@ function clickHandler(): void {
// Scroll to the first new comment and remove the `.is-comment-new` class
// from it.
const newestComment: HTMLElement = querySelector('.comment.is-comment-new');
// TODO: Check if the new comment is collapsed or is inside a collapsed
// comment and uncollapse it if so.
if (newestComment.offsetParent === null) {
// TODO: Instead of expanding all comments, only expand the ones necessary
// to make the comment visible.
const expandAllButton: HTMLButtonElement = querySelector(
'[data-js-comment-expand-all-button]'
);
expandAllButton.click();
}
newestComment.scrollIntoView({behavior: 'smooth'});
// TODO: Don't immediately remove the class after scrolling to it. But remove
// it when scrolling to the next new comment after this one. I've decided to