Next.js Discord

Discord Forum

Smooth Scroll not working

Unanswered
Cape lion posted this in #help-forum
Open in Discord
Cape lionOP
any idea why adding style={{scrollBehavior:'smooth'}}

in any manner breaks scroll navigation methods?
that's adding it inline, but adding it through style sheets, or as an option to the normal scroll methods, the scroll navigation just stops working entirely

frameRef.current?.scrollIntoView();

^ works (but doesn't if that css property is added)

frameRef.current?.scrollIntoView({ behavior: 'smooth' });

^ doesn't

15 Replies

@gin i think u should use scrollBehavior and scrollIntoView separately
Cape lionOP
I think I partially found the error. an error is being thrown in the function calling scroll, and since the smooth scroll isn't instant, when the error thrown it gets terminated
but really I'd like to continue the scroll regardless of error received
what error? something completely different?
Cape lionOP
it's an expected error response from my API
yeah but that should not interfere with it
Cape lionOP
when that promise rejects, no matter how far along the scroll is, it aborts
very odd
u should handle your scroll in a different function
and assign your element a ref
Cape lionOP
yeah I tried all of that
and sheck if its not null before u trigger scroll
Cape lionOP
ref first, as well as declaring it in it's own fn
just was grasping at straws trying diff things since it was non-sensically not working to me