Skip to content

Commit b1da620

Browse files
Fix: blog editor/dashboard auth race condition, mobile menu scrollable
1 parent 1270e8e commit b1da620

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/Pages/BlogDashboard.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
import PageLayout from '../components/PageLayout';
2020

2121
const BlogDashboard: React.FC = () => {
22-
const { currentUser, logout, isReviewer, isApprover } = useAuth();
22+
const { currentUser, logout, isReviewer, isApprover, loading: authLoading } = useAuth();
2323
const navigate = useNavigate();
2424
const [posts, setPosts] = useState<BlogPost[]>([]);
2525
const [loading, setLoading] = useState(true);
@@ -28,12 +28,12 @@ const BlogDashboard: React.FC = () => {
2828
const [showAccessLog, setShowAccessLog] = useState(false);
2929
const [accessLog, setAccessLog] = useState<AuditLogEntry[]>([]);
3030

31-
// Redirect if not logged in
31+
// Redirect if not logged in (wait for auth to finish loading first)
3232
useEffect(() => {
33-
if (!currentUser) {
33+
if (!authLoading && !currentUser) {
3434
navigate('/login');
3535
}
36-
}, [currentUser, navigate]);
36+
}, [currentUser, authLoading, navigate]);
3737

3838
// Fetch posts (filtered by role)
3939
useEffect(() => {

src/Pages/BlogEditor.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import PageLayout from '../components/PageLayout';
1313

1414
const BlogEditor: React.FC = () => {
1515
const { id } = useParams<{ id: string }>();
16-
const { currentUser, isReviewer } = useAuth();
16+
const { currentUser, isReviewer, loading: authLoading } = useAuth();
1717
const navigate = useNavigate();
1818

1919
const [title, setTitle] = useState('');
@@ -29,12 +29,12 @@ const BlogEditor: React.FC = () => {
2929
const [error, setError] = useState('');
3030
const [uploading, setUploading] = useState(false);
3131

32-
// Redirect if not logged in
32+
// Redirect if not logged in (wait for auth to finish loading first)
3333
useEffect(() => {
34-
if (!currentUser) {
34+
if (!authLoading && !currentUser) {
3535
navigate('/login');
3636
}
37-
}, [currentUser, navigate]);
37+
}, [currentUser, authLoading, navigate]);
3838

3939
// Load existing post if editing
4040
useEffect(() => {

src/components/NavBar.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,24 @@
9797
top: 80px;
9898
left: 0;
9999
width: 280px;
100-
min-height: calc(100vh - 80px);
100+
height: calc(100vh - 80px);
101+
max-height: calc(100vh - 80px);
101102
display: flex;
102103
flex-direction: column;
103104
align-items: flex-start;
104105
justify-content: flex-start;
105106
gap: 24px;
106107
padding: 32px 24px;
108+
padding-bottom: 48px;
107109
transition: all 0.3s ease-in-out;
108110
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25),
109111
0 0 0 1px rgba(255, 255, 255, 0.15);
110112
overflow-y: auto;
113+
overflow-x: hidden;
111114
z-index: 40;
112115

113116
/* Semi-transparent background with exact #e8e8e8 shade - shows pattern but prevents text overlap */
114117
background: rgba(232, 232, 232, 0.85);
115-
116-
/* Remove borders for clean transparent look */
117118
}
118119

119120
/* Remove textured overlay - no pseudo-element needed */

0 commit comments

Comments
 (0)