mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-29 18:13:47 +00:00
fix: scroll to start of tariffs section and wait for data to load
This commit is contained in:
@@ -519,15 +519,16 @@ export default function Subscription() {
|
|||||||
// Auto-scroll to tariffs section when coming from Dashboard "Продлить" button
|
// Auto-scroll to tariffs section when coming from Dashboard "Продлить" button
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const state = location.state as { scrollToExtend?: boolean } | null;
|
const state = location.state as { scrollToExtend?: boolean } | null;
|
||||||
if (state?.scrollToExtend && tariffsCardRef.current) {
|
// Wait for tariffs to load before scrolling
|
||||||
|
if (state?.scrollToExtend && tariffsCardRef.current && tariffs.length > 0) {
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
tariffsCardRef.current?.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
tariffsCardRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||||
}, 300);
|
}, 100);
|
||||||
// Clear the state to prevent re-scrolling on subsequent renders
|
// Clear the state to prevent re-scrolling on subsequent renders
|
||||||
window.history.replaceState({}, document.title);
|
window.history.replaceState({}, document.title);
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
}
|
}
|
||||||
}, [location.state]);
|
}, [location.state, tariffs.length]);
|
||||||
|
|
||||||
const copyUrl = () => {
|
const copyUrl = () => {
|
||||||
if (subscription?.subscription_url) {
|
if (subscription?.subscription_url) {
|
||||||
|
|||||||
Reference in New Issue
Block a user