From 99457209188d27bbb2dc4419fca023761500d46c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=BChler?= Date: Mon, 5 Aug 2024 13:55:23 +0200 Subject: [PATCH] Fix scroll into view not working for safari --- .../components/plugin-sidebar/plugin-sidebar.component.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/components/plugin-sidebar/plugin-sidebar.component.ts b/src/app/components/plugin-sidebar/plugin-sidebar.component.ts index 5defe74..d08a56d 100644 --- a/src/app/components/plugin-sidebar/plugin-sidebar.component.ts +++ b/src/app/components/plugin-sidebar/plugin-sidebar.component.ts @@ -408,7 +408,12 @@ export class PluginSidebarComponent implements OnInit, OnDestroy { scrollGroupIntoView(group: PluginGroup) { const groupElement = this.sidebar?.nativeElement?.querySelector(`[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' }); }); }