mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-05-07 02:03:55 -05:00
[PR #1602] [MERGED] fix(staffml): add pickRandom to keyboard effect and pickNext dep arrays #9214
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/harvard-edge/cs249r_book/pull/1602
Author: @Shashank-Tripathi-07
Created: 4/29/2026
Status: ✅ Merged
Merged: 4/30/2026
Merged by: @profvjreddi
Base:
dev← Head:fix/practice-keyboard-stale-closure📝 Commits (1)
bc4cca7fix(staffml): add pickRandom to keyboard effect and pickNext dep arrays📊 Changes
1 file changed (+18 additions, -18 deletions)
View changed files
📝
interviews/staffml/src/app/practice/page.tsx(+18 -18)📄 Description
Summary
Two related stale-closure bugs in
practice/page.tsx:Bug 1 -- keyboard shortcut
Npicks from wrong pool after filter changepickRandomis auseCallbackwith deps[pool, current, showAnswer]. When the user changes a filter (track, level, area, etc.),poolupdates andpickRandomgets a new identity. But the keyboarduseEffectonly listed[showAnswer, current]as deps -- it never re-registered the listener with the newpickRandom. PressingNafter a filter change would pick from the stale pre-filter question pool.Bug 2 --
pickNextalso calls stalepickRandomSame issue in
pickNext: deps were[reviewMode, pool]but it callspickRandom(), so the same staleness applied after a pool change.Fix:
pickRandomdeclaration before the keyboarduseEffect(satisfies declaration-before-use order)pickRandomto the keyboard effect dep array:[showAnswer, current, pickRandom]pickRandomtopickNextdep array:[reviewMode, pool, pickRandom]Repro steps
/practice, select "Cloud" + "L3"Non the keyboardTest plan
N-- verify picked question matches the new filterpickNextcorrectly transitions topickRandomwhen due queue is empty🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.