mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-26 13:35:16 +03:00
Fixed toasts not disappearing after settings reload (#18535)
refs https://www.notion.so/ghost/AdminX-feedback-27fc7f549bbf4a53bfa2e7b6e5643963?p=d8bb2da9a6534494ad5baf840bbfd785&pm=s - The error state remains visible after navigating away from settings - this fix resets the toast on initial load to ensure it doesn't persist if not needed --- <!-- Leave the line below if you'd like GitHub Copilot to generate a summary from your commit --> <!-- copilot:summary --> ### <samp>🤖 Generated by Copilot at 5c91fe7</samp> Improved notifications on settings page using `toast` function. Cleared old notifications on initial load to avoid confusion.
This commit is contained in:
parent
8a4e81fadd
commit
71a8df9f52
@ -6,6 +6,7 @@ import Users from './components/settings/general/Users';
|
||||
import useRouting from './hooks/useRouting';
|
||||
import {ReactNode, useEffect} from 'react';
|
||||
import {canAccessSettings, isEditorUser} from './api/users';
|
||||
import {toast} from 'react-hot-toast';
|
||||
import {topLevelBackdropClasses} from './admin-x-ds/global/modal/Modal';
|
||||
import {useGlobalData} from './components/providers/GlobalDataProvider';
|
||||
|
||||
@ -25,6 +26,11 @@ const MainContent: React.FC = () => {
|
||||
const {currentUser} = useGlobalData();
|
||||
const {route, updateRoute, loadingModal} = useRouting();
|
||||
|
||||
useEffect(() => {
|
||||
// resets any toasts that may have been left open on initial load
|
||||
toast.remove();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!canAccessSettings(currentUser) && route !== `staff/${currentUser.slug}`) {
|
||||
updateRoute(`staff/${currentUser.slug}`);
|
||||
|
Loading…
Reference in New Issue
Block a user