fix: Add key prop to force animation re-trigger on tab switch

Each page container now has key={currentTab} to ensure React unmounts and remounts the element on every tab switch, properly triggering the slide-in animation
This commit is contained in:
ZacharyZcR
2025-11-09 08:15:02 +08:00
parent fe127e045f
commit aa94851f4a

View File

@@ -179,14 +179,14 @@ function AppContent() {
style={{ display: showTerminalView ? "block" : "none" }} style={{ display: showTerminalView ? "block" : "none" }}
> >
{showTerminalView && ( {showTerminalView && (
<div className="animate-in fade-in slide-in-from-right-4 duration-300"> <div key={currentTab} className="animate-in fade-in slide-in-from-right-4 duration-300">
<AppView isTopbarOpen={isTopbarOpen} /> <AppView isTopbarOpen={isTopbarOpen} />
</div> </div>
)} )}
</div> </div>
{showHome && ( {showHome && (
<div className="h-screen w-full visible pointer-events-auto static overflow-hidden animate-in fade-in slide-in-from-right-4 duration-300"> <div key={currentTab} className="h-screen w-full visible pointer-events-auto static overflow-hidden animate-in fade-in slide-in-from-right-4 duration-300">
<Dashboard <Dashboard
onSelectView={handleSelectView} onSelectView={handleSelectView}
isAuthenticated={isAuthenticated} isAuthenticated={isAuthenticated}
@@ -198,7 +198,7 @@ function AppContent() {
)} )}
{showSshManager && ( {showSshManager && (
<div className="h-screen w-full visible pointer-events-auto static overflow-hidden animate-in fade-in slide-in-from-right-4 duration-300"> <div key={currentTab} className="h-screen w-full visible pointer-events-auto static overflow-hidden animate-in fade-in slide-in-from-right-4 duration-300">
<HostManager <HostManager
onSelectView={handleSelectView} onSelectView={handleSelectView}
isTopbarOpen={isTopbarOpen} isTopbarOpen={isTopbarOpen}
@@ -209,13 +209,13 @@ function AppContent() {
)} )}
{showAdmin && ( {showAdmin && (
<div className="h-screen w-full visible pointer-events-auto static overflow-hidden animate-in fade-in slide-in-from-right-4 duration-300"> <div key={currentTab} className="h-screen w-full visible pointer-events-auto static overflow-hidden animate-in fade-in slide-in-from-right-4 duration-300">
<AdminSettings isTopbarOpen={isTopbarOpen} /> <AdminSettings isTopbarOpen={isTopbarOpen} />
</div> </div>
)} )}
{showProfile && ( {showProfile && (
<div className="h-screen w-full visible pointer-events-auto static overflow-auto animate-in fade-in slide-in-from-right-4 duration-300"> <div key={currentTab} className="h-screen w-full visible pointer-events-auto static overflow-auto animate-in fade-in slide-in-from-right-4 duration-300">
<UserProfile isTopbarOpen={isTopbarOpen} /> <UserProfile isTopbarOpen={isTopbarOpen} />
</div> </div>
)} )}