Selecting a pen color leaves Example drawing in eraser mode
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript
- Domain
- frontend
Research direction
Start with the color-button handler and pointer handler in web/example-board.js, then compare their behavior with selectPen() in web/interview.js. Add or update the regression test in example-board.test.js to cover switching from Eraser to a pen color and explicitly selecting Eraser. Done when the selected color draws a pen stroke with the expected width, the toolbar states match the active tool, and Eraser still produces eraser strokes.
Written by the indexing model from the issue text.
Description
Problem and motivation
In the coding interview's Example drawing panel, selecting a pen color after using the eraser does not switch back to the pen. The color button becomes selected, but subsequent strokes still erase existing content. A candidate trying to annotate a diagram in another color can therefore erase it instead.
The color buttons have labels such as Pen Red, which suggest that selecting one activates that pen. The full whiteboard already follows this behavior, so the two drawing surfaces respond differently to the same action.
Steps to reproduce
- Select Editor mode and enable Example drawing in the lobby.
- Start an interview and enter the live coding phase.
- Expand Example drawing and draw a black line.
- Select Eraser.
- Select the red pen color.
- Draw across the black line.
Expected:
Selecting the red pen color activates the pen, and the next stroke draws a red line.
Actual:
The red color is selected, but Eraser remains active and the next stroke erases the black line.
Initial analysis
In web/example-board.js, the color-button handler updates color and the color buttons' aria-pressed states, but leaves tool unchanged. The pointer handler later passes that unchanged tool to model.begin(), so the board continues producing eraser strokes.
The full whiteboard handles this through selectPen() in web/interview.js, which sets both the color and board.tool = "pen" before updating the toolbar. Applying the same interaction rule to Example drawing would make the selected color and the active drawing tool agree.
Proposed implementation
Keep the change within the Example drawing toolbar. Selecting a color should activate the pen and update both the pen/eraser buttons and the color buttons to reflect the resulting state. Eraser behavior should remain available through its explicit control.
Add a regression test that selects Eraser, selects a pen color, and draws a stroke. Assert that the stroke uses the selected color and pen width, that Pen is active, and that Eraser is inactive. Also verify that explicitly selecting Eraser still produces an eraser stroke.
Verification so far
At checkout revision fd7c23c, a module-level reproduction using the actual mountExampleBoard() implementation with simulated DOM and canvas objects produced a white, width-24 eraser stroke after selecting Eraser and then Pen Red. The red color button and Eraser both remained pressed.
The existing example-board.test.js suite passed all eight tests. The interaction above has not yet been manually verified in a real browser; the steps listed above are the browser verification procedure.
- Dominant language
- Rust
- Stars
- 177
- Forks
- 100
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 168
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sysprog21/codetrial
-
Python tests lose every result when the solution returns inf or NaNPossibly taken @shensyuan claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
sysprog21/codetrial#419 · 3 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Allow deselecting a chosen problem card by clicking it againPossibly taken @woohsin claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
sysprog21/codetrial#392 · 4 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Audio output can be confirmed without playing a test soundPossibly taken @ChenYingHan1121 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
sysprog21/codetrial#359 · 5 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Add a Copy code button to the final reportPossibly taken @yansawu claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
sysprog21/codetrial#318 · 5 comments · 2 reactions · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 76/100
Maintainers usually reply within 1 day
All issues in sysprog21/codetrial
Similar issues
-
state:triage-needed
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug P2
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
pedrovgs/UseCaseCoverage#23 ·
-
area: library data-loss tier: p0 type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
llm translation
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day