Skip to content

Commit

Opening Notifications lights only the row you chose: a sidebar whose rows differ only by their query shows a row as loading only when the page on its way is that row's, not every row on the same path.

syntaqxcommitted Parentcf322ccBrowse files
1 file+9−10/1 viewed
+9−1
127127 children: ReactNode;
128128 }) {
129129 const { pathname } = useLocation();
130+ const navigation = useNavigation();
131+ // NavLink's own pending state compares paths only, so a list whose rows
132+ // differ by query (Notifications' views and reasons) would light every
133+ // row while one loads. Where the list says which row is current, a row
134+ // is pending only when the page on its way is that row's, query and all.
135+ const loading = navigation.location;
136+ const pendingHere = loading != null && `${loading.pathname}${loading.search}` === to;
130137 return (
131138 <NavLink
132139 to={to}
136143 const current =
137144 lit ??
138145 (isActive || [also ?? []].flat().some((prefix) => pathname === prefix || pathname.startsWith(prefix + "/")));
146+ const pending = lit === undefined ? isPending : pendingHere;
139147 return `group flex h-8 items-center gap-2.5 rounded-md px-2 text-[0.8125rem] transition-colors ${
140148 current
141149 ? "bg-raised font-medium text-fg"
142− : isPending
150+ : pending
143151 ? "bg-raised/60 text-fg"
144152 : "text-muted hover:bg-raised/60 hover:text-fg"
145153 }`;