Skip to content

Commit 705a378

Browse files
Updates scroll positioning for selected commits when composer loads
1 parent ee24d20 commit 705a378

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/webviews/apps/plus/composer/components/commits-panel.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,23 @@ export class CommitsPanel extends LitElement {
488488
const commitItem = this.shadowRoot?.querySelector(
489489
`gl-commit-item[data-commit-id="${firstNonLockedCommit.id}"]`,
490490
);
491-
commitItem?.scrollIntoView({ block: 'center' });
491+
if (!commitItem) return;
492+
493+
const container = this.shadowRoot?.querySelector('.container.scrollable');
494+
if (!container) {
495+
commitItem.scrollIntoView({ block: 'center' });
496+
return;
497+
}
498+
499+
const itemRect = commitItem.getBoundingClientRect();
500+
const containerRect = container.getBoundingClientRect();
501+
const itemTop = itemRect.top - containerRect.top + container.scrollTop;
502+
const targetPosition = itemTop - containerRect.height * 0.1;
503+
504+
container.scrollTo({
505+
top: Math.max(0, targetPosition),
506+
behavior: 'smooth',
507+
});
492508
});
493509
}
494510

0 commit comments

Comments
 (0)