Skip to content

Commit

Permalink
Merge pull request #17374 from opf/bug/59458-activity-tab-does-not-sc…
Browse files Browse the repository at this point in the history
…roll-to-the-bottom-or-correct-comment-on-mobile

Bug/59458 activity tab does not scroll to the bottom or correct comment on mobile
  • Loading branch information
jjabari-op authored Dec 10, 2024
2 parents 3fbe773 + 403fa49 commit bb9b1c9
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,18 @@ export default class IndexController extends Controller {
private tryScroll(activityId:string, attempts:number, maxAttempts:number) {
const scrollableContainer = this.getScrollableContainer();
const activityElement = document.getElementById(`activity-anchor-${activityId}`);
const topPadding = 70;

if (activityElement && scrollableContainer) {
scrollableContainer.scrollTop = activityElement.offsetTop - 70;
scrollableContainer.scrollTop = 0;

setTimeout(() => {
const containerRect = scrollableContainer.getBoundingClientRect();
const elementRect = activityElement.getBoundingClientRect();
const relativeTop = elementRect.top - containerRect.top;

scrollableContainer.scrollTop = relativeTop - topPadding;
}, 50);
} else if (attempts < maxAttempts) {
setTimeout(() => this.tryScroll(activityId, attempts + 1, maxAttempts), 1000);
}
Expand Down

0 comments on commit bb9b1c9

Please sign in to comment.