mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 17:43:47 +00:00
Fix AdminSettings mobile: scroll to top on open and add safe area padding
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useState, useMemo } from 'react'
|
||||
import { useState, useMemo, useEffect } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { adminSettingsApi, SettingDefinition } from '../api/adminSettings'
|
||||
@@ -28,6 +28,16 @@ export default function AdminSettings() {
|
||||
// Favorites hook
|
||||
const { favorites, toggleFavorite, isFavorite } = useFavoriteSettings()
|
||||
|
||||
// Scroll to top on mount and section change (fix for mobile webviews)
|
||||
useEffect(() => {
|
||||
// Use requestAnimationFrame for smoother scroll on mobile
|
||||
requestAnimationFrame(() => {
|
||||
window.scrollTo({ top: 0, behavior: 'instant' })
|
||||
document.documentElement.scrollTop = 0
|
||||
document.body.scrollTop = 0
|
||||
})
|
||||
}, [activeSection])
|
||||
|
||||
// Queries
|
||||
const { data: themeColors } = useQuery({
|
||||
queryKey: ['theme-colors'],
|
||||
@@ -151,7 +161,7 @@ export default function AdminSettings() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen">
|
||||
<div className="flex min-h-screen pt-safe">
|
||||
{/* Mobile overlay */}
|
||||
{mobileMenuOpen && (
|
||||
<div
|
||||
|
||||
@@ -890,6 +890,10 @@
|
||||
padding-bottom: calc(0.5rem + var(--safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.pt-safe {
|
||||
padding-top: env(safe-area-inset-top, 0px);
|
||||
}
|
||||
|
||||
/* Skeleton loader */
|
||||
.skeleton {
|
||||
@apply bg-dark-800 rounded-lg animate-pulse;
|
||||
|
||||
Reference in New Issue
Block a user