Fix: Uncollapse all comments when the target is invisible (fixes #8).
This commit is contained in:
parent
ad74b77fd8
commit
26cd9e3a13
|
@ -27,8 +27,15 @@ function clickHandler(): void {
|
||||||
// Scroll to the first new comment and remove the `.is-comment-new` class
|
// Scroll to the first new comment and remove the `.is-comment-new` class
|
||||||
// from it.
|
// from it.
|
||||||
const newestComment: HTMLElement = querySelector('.comment.is-comment-new');
|
const newestComment: HTMLElement = querySelector('.comment.is-comment-new');
|
||||||
// TODO: Check if the new comment is collapsed or is inside a collapsed
|
if (newestComment.offsetParent === null) {
|
||||||
// comment and uncollapse it if so.
|
// 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'});
|
newestComment.scrollIntoView({behavior: 'smooth'});
|
||||||
// TODO: Don't immediately remove the class after scrolling to it. But remove
|
// 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
|
// it when scrolling to the next new comment after this one. I've decided to
|
||||||
|
|
Loading…
Reference in New Issue