fix: recalculate notification dropdown position after content loads

The dropdown position was only clamped on initial render when the panel
was empty. After async notifications loaded and the panel grew taller,
the position was never recalculated. Add an effect that re-clamps when
notifications or loading state changes.
This commit is contained in:
Usman Baig
2026-03-19 00:48:46 +01:00
parent 89343caf65
commit a31f183b7b

View File

@@ -104,6 +104,13 @@ export default function NotificationCenter({ anchor = 'bottom', variant = 'defau
}
}, [open, updatePosition])
// Recalculate position after content changes (notifications load, loading state)
useEffect(() => {
if (open && anchor === 'right') {
requestAnimationFrame(() => updatePosition())
}
}, [notifications, loading, open, anchor, updatePosition])
// * Poll unread count in background (when authenticated)
useEffect(() => {
fetchUnreadCount()