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: {
142 142
143 const insertFromBank = async (bankQuestionId: string, subjectId: string) => {143 const insertFromBank = async (bankQuestionId: string, subjectId: string) => {
144 await postExamQuestionFromBank(props.examId, bankQuestionId, subjectId);144 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);
146 setFlash(t("bank.inserted"));150 setFlash(t("bank.inserted"));
147 await refetch();151 await refetch();
148 };152 };
@@ -268,7 +272,7 @@ export function ExamQuestionsPanel(props: {
268 <BankQuestionPicker272 <BankQuestionPicker
269 subjects={subjects() ?? []}273 subjects={subjects() ?? []}
270 onInsert={insertFromBank}274 onInsert={insertFromBank}
271- onCancel={() => closeAfterGesture(() => setBankOpen(false))}275+ onCancel={() => setBankOpen(false)}
272 />276 />
273 </SidePanel>277 </SidePanel>
274 278
src/pages/builder-login-page.tsxmodified+3 -0
@@ -6,6 +6,7 @@ import { AuthPageShell } from "@/components/auth/auth-page-shell";
6 import { Button } from "@/components/ui/button";6 import { Button } from "@/components/ui/button";
7 import { Input } from "@/components/ui/input";7 import { Input } from "@/components/ui/input";
8 import { Label } from "@/components/ui/label";8 import { Label } from "@/components/ui/label";
9+import { GuestGuard } from "@/components/layout/guest-guard";
9 import { IconEye, IconEyeOff } from "@/components/ui/icons";10 import { IconEye, IconEyeOff } from "@/components/ui/icons";
10 import { PageSpinner } from "@/components/ui/page-spinner";11 import { PageSpinner } from "@/components/ui/page-spinner";
11 import { useAuth } from "@/stores/auth-context";12 import { useAuth } from "@/stores/auth-context";
@@ -20,9 +21,11 @@ const MAX_PASSWORD_LEN = 128;
20 21
21 export default function BuilderLoginPage() {22 export default function BuilderLoginPage() {
22 return (23 return (
24+ <GuestGuard>
23 <BuilderProvider>25 <BuilderProvider>
24 <BuilderLoginGate />26 <BuilderLoginGate />
25 </BuilderProvider>27 </BuilderProvider>
28+ </GuestGuard>
26 );29 );
27 }30 }
28 31
src/test-setup.tsmodified+3 -0
@@ -2,6 +2,9 @@
2 // --localstorage-file is provided, and this jsdom version does not expose one2 // --localstorage-file is provided, and this jsdom version does not expose one
3 // for the configured test origin. Keep the test storage local to each worker.3 // for the configured test origin. Keep the test storage local to each worker.
4 if (typeof window !== "undefined") {4 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;
5 const values = new Map<string, string>();8 const values = new Map<string, string>();
6 const storage = {9 const storage = {
7 get length() { return values.size; },10 get length() { return values.size; },