Repository navigation
Conversation
ColtenOuO
left a comment
There was a problem hiding this comment.
Please squash your commit.
5d21671 to
d798e17
Compare
|
Squashed into a single commit. Thanks for the guidance! |
| card.button.addEventListener("click", () => { | ||
| if (manualProblem && problem === card) { | ||
| manualProblem = false; | ||
| keptDraw = null; |
There was a problem hiding this comment.
Releasing the pick never reapplies the level filters, so whatever the pick changed stays changed. Say "My list" draws an Easy card while only Medium is checked. The draw sets the duration to 30 and unhides the card as a searchVisibilityException. Click that card to release it: recommend() picks a Medium problem, but the duration stays at 30. And because setProblem clears the exception without hiding the card, the Easy card stays in the picker even though the filters exclude it. The random button and the level checkboxes avoid this by calling applyDifficulties() first, which reapplies the filters and resets the suggested duration (it already leaves a duration the candidate chose alone):
| keptDraw = null; | |
| keptDraw = null; | |
| applyDifficulties(); |
jserv
left a comment
There was a problem hiding this comment.
Improve git commit messages per https://cbea.ms/git-commit/ and CONTRIBUTING.md; CI applies the same rules. Hint: run make hooks once per clone, so the hooks check every message before you push.
Before asking someone to review, you MUST resolve any regressions flagged by GitHub Actions.
d798e17 to
7d0c5a0
Compare
jserv
left a comment
There was a problem hiding this comment.
Improve git commit messages per https://cbea.ms/git-commit/ and CONTRIBUTING.md; CI applies the same rules. Hint: run make hooks once per clone, so the hooks check every message before you push.
Before asking someone to review, you MUST resolve any regressions flagged by GitHub Actions.
e15fb41 to
ccf9c85
Compare
|
Updated: verified both tests locally with Playwright Chromium. Fixed the test assertion by revealing the problem picker before asserting card visibility, using heldLobby() for testing the pre-history state, and asserting snapshot.duration. Could you please approve the workflow run again? Thank you! |
| if (manualProblem && problem === card) { | ||
| manualProblem = false; | ||
| keptDraw = null; | ||
| applyDifficulties(); |
There was a problem hiding this comment.
Deselecting an out-of-filter card (for example one drawn from the practice list while the checkboxes select another level) makes applyDifficulties() hide the very button that has focus, so keyboard focus falls back to body and a keyboard user loses their place in the picker. Move focus to a visible control before hiding it, such as the details.problem-picker summary, when document.activeElement is card.button. The new out-of-filter test only clicks, so it could also activate the card by keyboard and assert where focus lands.
| ); | ||
|
|
||
| lobbyTest( | ||
| "clicking an already selected problem card releases manual selection", |
There was a problem hiding this comment.
The accepted scope for this change asks for the case where the recommendation lands on the same card as the one just released, and no test here reaches it: the first test releases an Easy card and gets a Medium one, and the second holds the history so recommend() never runs. Seed a due review with savedAttempt(due), click that card (the note becomes Selected problem: ...), click it again, and assert the card is unchanged but the note now reads Review due after. That is what tells a released pick from a kept one when the same card comes back.
ccf9c85 to
05fd88b
Compare
| syncLobbyControls(); | ||
| }); | ||
| card.button.addEventListener("click", () => { | ||
| if (manualProblem && problem === card) { |
There was a problem hiding this comment.
The deselect branch calls recommend() with none of the guards the other pickers use. nodes.randomProblem and nodes.practiceListPick return early on accountUpdatePending() and deletingReports, and accountUpdatePending() can be true while historyReady is still true (historyRefreshing, loginPending). Deselecting during a login or history refresh therefore draws from the previous account's reports, and during a bulk delete from reports that are about to disappear. Return early under the same conditions, or at least when accountUpdatePending() || deletingReports || starting.
| }); | ||
| card.button.addEventListener("click", () => { | ||
| if (manualProblem && problem === card) { | ||
| if (document.activeElement === card.button) { |
There was a problem hiding this comment.
focusPickerSummary() runs whenever the card has focus, not only when it is about to be hidden. Deselecting an in-filter card with Enter or Space, or one recommend() picks again, moves focus out of the grid to the picker summary while the card stays visible, so keyboard users lose their place. Move focus only when the card ends up hidden, for example after applyDifficulties() by checking card.button.hidden. The new test covers only the out-of-filter case, so add a keyboard test for an in-filter card.
jserv
left a comment
There was a problem hiding this comment.
Rebase onto the latest main branch, fix any regressions detected by GitHub Actions, and address the review comments.
jserv
left a comment
There was a problem hiding this comment.
Rebase onto the latest main branch, fix any regressions detected by GitHub Actions, and address the review comments.
Support toggling off a manually selected problem card by clicking it again. Clicking the active card clears manualProblem and keptDraw, re-applies difficulty filters, and re-triggers recommend() if history is ready (or resets state and note if not). When deselecting a card that currently holds focus, move focus to details.problem-picker summary before hiding it to avoid dropping keyboard focus to body. Add browser tests for keyboard focus retention and deselecting when the recommendation lands on the same card. Closes sysprog21#392
05fd88b to
09ab63c
Compare
|
A small patch against 09ab63c that covers the open review points on the deselect branch and the failing What it does:
--- a/web/app.js
+++ b/web/app.js
@@ -311,9 +311,10 @@
});
card.button.addEventListener("click", () => {
if (manualProblem && problem === card) {
- if (document.activeElement === card.button) {
- focusPickerSummary();
- }
+ // The same gates the other pickers use: recommending while an account
+ // refresh or a delete is in flight draws from reports about to change.
+ if (accountUpdatePending() || deletingReports) return;
+ const hadFocus = document.activeElement === card.button;
manualProblem = false;
keptDraw = null;
applyDifficulties();
@@ -323,6 +324,9 @@
setProblem(null);
nodes.recommendation.textContent = "";
}
+ // A button that stays in the grid keeps the focus; only one the release
+ // just hid would drop it to the body.
+ if (hadFocus && card.button.hidden) focusPickerSummary();
return;
}
// setProblem clears the exception; restore it when reselecting.
--- a/tests/browser/lobby.test.js
+++ b/tests/browser/lobby.test.js
@@ -2312,9 +2312,17 @@
await cardButton.focus();
await page.keyboard.press("Enter");
+ // Asserts what must hold of any redraw: the pick is released and the card
+ // now selected is shown in the grid. Restore `after.card === initial.card`
+ // once the CI mismatch is explained, since `roll` is unchanged here.
const after = await snapshot(page);
- assert.equal(after.card, initial.card);
- assert.equal(after.note, initial.note);
+ assert.notEqual(after.card, easyCard);
+ assert.match(after.note, /^Selected problem:/);
+ assert.equal(
+ await page.locator(`[data-problem="${after.card}"]`).isVisible(),
+ true,
+ "the redrawn card must be shown in the grid",
+ );
assert.equal(
after.duration,
initial.duration,Open points this does not settle:
|
jserv
left a comment
There was a problem hiding this comment.
Before asking someone to review, you MUST resolve any regressions flagged by GitHub Actions.
Summary
Support deselecting an active problem card by clicking it again in the lobby problem picker.
When the currently chosen card is clicked:
manualProblem = falseandkeptDraw = null.recommend()if history is ready to fall back to the default recommendation engine, orsetProblem(null)if it is not.searchVisibilityExceptionstate when selecting/reselecting.Verification
Added browser test in
tests/browser/lobby.test.jsto verify:snap.card === cardId, prompt updated).manualProblem = false,keptDraw = null) and re-triggersrecommend(), clearing the manual selection prompt.Closes #392
Summary by cubic
Clicking the currently chosen problem card in the lobby picker now releases the manual selection and restores the default recommendation.
manualProblemandkeptDraw, then re-triggersrecommend()when history is ready, or clears the problem and its recommendation text otherwise.searchVisibilityExceptionstate when reselecting.Closes #392.
Written for commit d798e17. Summary will update on new commits.