Selecting a pen color leaves Example drawing in eraser mode
メンテナーはふだん 1 日以内に返信
@Aa99841 がすでに取り組んでいます。
2026年10月23日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript
- 領域
- frontend
調査の方向性
まず web/example-board.js の色ボタンハンドラーとポインターハンドラーを確認し、その後、web/interview.js の selectPen() と動作を比較します。Eraser からペンの色への切り替えと、Eraser の明示的な選択を対象とするよう、example-board.test.js の回帰テストを追加または更新してください。選択した色で期待される幅のペンストロークが描画され、ツールバーの状態がアクティブなツールと一致し、Eraser が引き続き消しゴムのストロークを生成すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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 applying the same interaction rule to Example drawing would make the two drawing surfaces more consistent.
I reproduced this behavior during an actual interview. Selecting a pen color after using the eraser did not resume drawing, making it difficult to alternate between erasing parts of a diagram and adding annotations in different colors.
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 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.
Analysis
In web/example-board.js, the color-button handler updates color and the color buttons' aria-pressed attributes, but leaves tool unchanged. The pointer handler subsequently passes the active tool and selected color to model.begin(). Because the active tool is still Eraser, the model correctly creates an eraser stroke.
The full whiteboard provides an existing reference in web/interview.js: selectPen() sets the color, activates Pen through board.tool = "pen", and updates the toolbar.
The relevant state in mountExampleBoard() consists of two values:
tooldetermines whether the next stroke draws or erases.colorstores the selected pen color.
The proposed interaction is to activate Pen whenever a pen color is selected, while preserving the stored pen color when switching to Eraser.
| User action | Active tool | Stored pen color |
|---|---|---|
| Select a pen color | Pen | Update to the selected color |
| Select Eraser | Eraser | Preserve the current color |
| Select Pen | Pen | Preserve the current color |
These results indicate that the selected color is retained and applied correctly when Pen is active. The issue concerns the toolbar state transition rather than the drawing model.
The existing example-board.test.js suite passed all eight tests at the time of the initial investigation. The new interaction has not yet been verified in a real browser.
Acceptance criteria
- Selecting any pen color in Example drawing immediately activates Pen.
- The toolbar accurately reflects the active tool and selected color.
- The next stroke uses the selected color and pen width.
- Selecting Eraser explicitly continues to produce eraser strokes.
- The stored pen color is preserved when switching tools.
- Undo, replay, and the active-stroke guard continue to work as expected.
- Regression coverage verifies the Eraser-to-Pen transition.
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 applying the same interaction rule to Example drawing would make the two drawing surfaces more consistent.
I reproduced this behavior during an actual interview. Selecting a pen color after using the eraser did not resume drawing, making it difficult to alternate between erasing parts of a diagram and adding annotations in different colors.
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 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.
Analysis
In web/example-board.js, the color-button handler updates color and the color buttons' aria-pressed attributes, but leaves tool unchanged. The pointer handler subsequently passes the active tool and selected color to model.begin(). Because the active tool is still Eraser, the model correctly creates an eraser stroke.
The full whiteboard provides an existing reference in web/interview.js: selectPen() sets the color, activates Pen through board.tool = "pen", and updates the toolbar.
The relevant state in mountExampleBoard() consists of two values:
tooldetermines whether the next stroke draws or erases.colorstores the selected pen color.
The proposed interaction is to activate Pen whenever a pen color is selected, while preserving the stored pen color when switching to Eraser.
| User action | Active tool afterwards | Stored pen color |
|---|---|---|
| Select a pen color | Pen | Update to the selected color |
| Select Eraser | Eraser | Preserve the current color |
| Select Pen | Pen | Preserve the current color |
Selecting a color should activate Pen even when the selected color has not changed. For example, if red is already the stored pen color, selecting Pen Red while Eraser is active should resume drawing in red.
Proposed implementation
Keep the change within web/example-board.js.
When a pen color is selected, update both the stored color and the active tool, then refresh the toolbar state. The Pen/Eraser buttons, color selection, and corresponding aria-pressed attributes should consistently reflect the resulting state.
The existing separation between the drawing-tool and pen-color controls can remain. The important behavior is that selecting a color activates Pen and makes the active tool clear to the user.
The existing if (drag) return guard should remain before changing either state value, so tool or color selection cannot alter a stroke already in progress.
No changes to the shared drawing model, operation format, replay mechanism, or backend should be necessary. The model already derives stroke appearance from the active tool: pen strokes use the selected color and pen width, while eraser strokes use the white background and eraser width.
Tool and color selection alone should not create a stroke operation, add an Undo entry, or publish a drawing.
Regression tests
The existing browser test selects Pen before selecting a pen color, so it does not cover the Eraser-to-Pen transition.
Add a focused regression test that:
- Draws an initial black line.
- Selects Eraser.
- Selects Pen Red.
- Verifies that Pen is active and Eraser is inactive.
- Draws across the initial line.
- Verifies that the new stroke uses
#c2261band pen width3.
Additional cases should verify that:
- Selecting the same color while Eraser is active reactivates Pen.
- Selecting Pen after erasing preserves the previously selected color.
- Explicitly selecting Eraser still produces an eraser stroke with the expected background color and width.
- Undo removes the latest stroke and restores the preceding drawing.
- Tool and color changes remain guarded during an active stroke.
- Selecting a color without drawing does not create a stroke operation.
The existing test for ordinary color selection can remain unchanged.
Verification status
At checkout revision [fd7c23c](https://github.com/sysprog21/codetrial/commit/fd7c23c1594ac9ecc630918bbf3ac87126b426af), a module-level reproduction using the actual mountExampleBoard() implementation with simulated DOM and canvas objects produced the following results:
| Selection sequence | Stroke color | Stroke width |
|---|---|---|
| Red | #c2261b |
3 |
| Eraser → Red | #ffffff |
24 |
| Eraser → Black | #ffffff |
24 |
| Eraser → Red → Pen | #c2261b |
3 |
These results indicate that the selected color is retained and applied correctly when Pen is active. The issue concerns the toolbar state transition rather than the drawing model.
The existing example-board.test.js suite passed all eight tests at the time of the initial investigation. The new interaction has not yet been verified in a real browser.
Acceptance criteria
- Selecting any pen color in Example drawing immediately activates Pen.
- The toolbar accurately reflects the active tool and selected color.
- The next stroke uses the selected color and pen width.
- Selecting Eraser explicitly continues to produce eraser strokes.
- The stored pen color is preserved when switching tools.
- Undo, replay, and the active-stroke guard continue to work as expected.
- Regression coverage verifies the Eraser-to-Pen transition.
- 主要言語
- Rust
- スター
- 177
- フォーク
- 100
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 182
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sysprog21/codetrial のほかの issue
-
Python tests lose every result when the solution returns inf or NaN対応中かも @shensyuan が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
sysprog21/codetrial#419 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Allow deselecting a chosen problem card by clicking it again対応中かも @woohsin が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
sysprog21/codetrial#392 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Audio output can be confirmed without playing a test sound対応中かも @ChenYingHan1121 が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
sysprog21/codetrial#359 · コメント 5 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Add a Copy code button to the final report対応中かも @yansawu が 5 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
sysprog21/codetrial#318 · コメント 6 件 · リアクション 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 18/100
sysprog21/codetrial#451 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
sysprog21/codetrial の issue をすべて見る
似ている issue
-
Docker host resolution missing default rootless Docker path対応中かも @500B が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
testcontainers/testcontainers-rs#1000 ·
メンテナーはふだん 3 日以内に返信
-
bug needs triage P3
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
pbakaus/impeccable#1143 ·
メンテナーはふだん 1 日以内に返信
-
Bundled uv is never updated and trusts the compromised eMudhra certificates対応中かも @FabienDanieau が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
foxglove/mcap#1907 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信