Skip to content

Commit

Permalink
Fix scroll into view not working for safari
Browse files Browse the repository at this point in the history
  • Loading branch information
buehlefs committed Aug 5, 2024
1 parent 424b370 commit 9945720
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,12 @@ export class PluginSidebarComponent implements OnInit, OnDestroy {
scrollGroupIntoView(group: PluginGroup) {
const groupElement = this.sidebar?.nativeElement?.querySelector<HTMLDetailsElement>(`[data-group="${group.key}"]`);
if (groupElement) {
window.requestIdleCallback(() => {
let caller: (calback: () => void) => void = window.requestIdleCallback;
if (caller == null) {
// fix for safari/older browsers
caller = Promise.resolve().then;
}
caller(() => {
groupElement.scrollIntoView({ behavior: 'smooth', block: 'start' });
});
}
Expand Down

0 comments on commit 9945720

Please sign in to comment.