F
Filament8mo ago
Vp

Auto scroll to selected navigation not implement in spa() mode?

Today I am just checking out spa() mode and everything seems working so far in resources, pages etc., but notice small issue, I am not sure whether this is intentional or not. As we can see from video, If I am not using spa then the active sidebar is showing in the center (auto scroll to selected navigation) but If I enable spa then it's showing from top (from Dashboard). Before (last month) I used this code to auto scroll to selected navigation, but I am not sure in which version this is included in core so I removed from my providers and it's working fine still, but not in spa()
// now I completely removed this from providers
Filament::registerRenderHook(
'panels::scripts.before',
fn () => new HtmlString(html: "
<script>
document.addEventListener('DOMContentLoaded', function(){
setTimeout(() => {
const activeSidebarItem = document.querySelector('.fi-sidebar-item-active');
const sidebarWrapper = document.querySelector('.fi-sidebar-nav');

if (activeSidebarItem && sidebarWrapper) {
sidebarWrapper.style.scrollBehavior = 'smooth';

sidebarWrapper.scrollTo(0, activeSidebarItem.offsetTop - 450);
}
}, 300)
});
</script>
"));
// now I completely removed this from providers
Filament::registerRenderHook(
'panels::scripts.before',
fn () => new HtmlString(html: "
<script>
document.addEventListener('DOMContentLoaded', function(){
setTimeout(() => {
const activeSidebarItem = document.querySelector('.fi-sidebar-item-active');
const sidebarWrapper = document.querySelector('.fi-sidebar-nav');

if (activeSidebarItem && sidebarWrapper) {
sidebarWrapper.style.scrollBehavior = 'smooth';

sidebarWrapper.scrollTo(0, activeSidebarItem.offsetTop - 450);
}
}, 300)
});
</script>
"));
My questions is "Is this intentional or bug?"
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server