forge
Explore
Log in

Don't you dare go Hollow

🛠️ close bank picker and guard auth pages

Browse files at this commit

0069847be17c816a489f22e7b2c04c00a01be81eBurak BoduroğluParent: 105e652
  • fix
    • 🛠️ close bank picker and guard auth pages
Show full message
fix: 🛠️ close bank picker and guard auth pages

- close the bank question panel immediately after insert or cancel

- redirect authenticated school users away from builder login

- silence jsdom scrollTo warnings in component tests
src/components/exams/exam-questions-panel.tsxmodified+6 -2
@@ -142,7 +142,11 @@ export function ExamQuestionsPanel(props: {
142142
143143 const insertFromBank = async (bankQuestionId: string, subjectId: string) => {
144144 await postExamQuestionFromBank(props.examId, bankQuestionId, subjectId);
145- closeAfterGesture(() => setBankOpen(false));
145+ // The request finishes after the original pointer gesture, so deferring
146+ // this close leaves the panel open until another event loop turn and can
147+ // race with the surrounding refetch. Close the controlled surface now;
148+ // the async request already guarantees the tap cannot fall through.
149+ setBankOpen(false);
146150 setFlash(t("bank.inserted"));
147151 await refetch();
148152 };
@@ -268,7 +272,7 @@ export function ExamQuestionsPanel(props: {
268272 <BankQuestionPicker
269273 subjects={subjects() ?? []}
270274 onInsert={insertFromBank}
271- onCancel={() => closeAfterGesture(() => setBankOpen(false))}
275+ onCancel={() => setBankOpen(false)}
272276 />
273277 </SidePanel>
274278
src/pages/builder-login-page.tsxmodified+6 -3
@@ -6,6 +6,7 @@ import { AuthPageShell } from "@/components/auth/auth-page-shell";
66 import { Button } from "@/components/ui/button";
77 import { Input } from "@/components/ui/input";
88 import { Label } from "@/components/ui/label";
9+import { GuestGuard } from "@/components/layout/guest-guard";
910 import { IconEye, IconEyeOff } from "@/components/ui/icons";
1011 import { PageSpinner } from "@/components/ui/page-spinner";
1112 import { useAuth } from "@/stores/auth-context";
@@ -20,9 +21,11 @@ const MAX_PASSWORD_LEN = 128;
2021
2122 export default function BuilderLoginPage() {
2223 return (
23- <BuilderProvider>
24- <BuilderLoginGate />
25- </BuilderProvider>
24+ <GuestGuard>
25+ <BuilderProvider>
26+ <BuilderLoginGate />
27+ </BuilderProvider>
28+ </GuestGuard>
2629 );
2730 }
2831
src/test-setup.tsmodified+3 -0
@@ -2,6 +2,9 @@
22 // --localstorage-file is provided, and this jsdom version does not expose one
33 // for the configured test origin. Keep the test storage local to each worker.
44 if (typeof window !== "undefined") {
5+ // jsdom intentionally does not implement scrolling and logs a warning when
6+ // UI code calls it. Scrolling is outside the scope of these component tests.
7+ window.scrollTo = () => undefined;
58 const values = new Map<string, string>();
69 const storage = {
710 get length() { return values.size; },