Skip to content

fix: even out the pen/highlighter middle size dot - #562

Merged
vibhavkatre merged 1 commit into
frappe:mainfrom
bvnaik05:fix/pen-highlighter-size-dot-scaling
Aug 27, 2026
Merged

fix: even out the pen/highlighter middle size dot#562
vibhavkatre merged 1 commit into
frappe:mainfrom
bvnaik05:fix/pen-highlighter-size-dot-scaling

Conversation

@bvnaik05

Copy link
Copy Markdown
Contributor

Problem

The pen and highlighter size pickers show three preview dots (small/medium/large) meant to be visibly, proportionally distinct. In practice, the middle dot barely differed from the small one — small and medium read as the same size, with the only real jump landing between medium and large.

Root cause

dotStyle scaled a size's preview dot by that size's value position within the row's own range: (size - smallest) / (largest - smallest).

The pen row's widths are [2, 4, 8] — not evenly spaced (gaps of 2 and 4). The middle value (4) sits only a third of the way between 2 and 8, so its dot landed close to the small dot's diameter, with the real jump saved for the small→large or medium→large step. The highlighter row ([10, 18, 26]) happens to be evenly spaced, so it didn't show the same defect as visibly — which is part of why this survived a first pass at #498.

Fix

Scale by index in the row instead of by value. Every row always has exactly three options, so three evenly-stepped diameters (min, midpoint, max) read as small/medium/large regardless of how far apart the underlying widths happen to be — order is preserved (the arrays are already ascending), just the step size is now even.

Extracted dotStyle out of WhiteboardTools.vue into frontend/src/diagram/sizeDot.js so it has a real, importable unit test covering the exact case that broke — sizeDots.test.js used to carry a hand-restated copy of the scaling logic because the .vue file wasn't importable from the browser-free test env; it now imports the real function instead of maintaining a parallel copy that could drift.

Testing

  • yarn vitest run — 150 files / 1735 tests pass.
  • New sizeDot.test.js: asserts the middle option is evenly between min/max regardless of value spacing, and pins the exact pen-vs-highlighter case that motivated the fix.
  • sizeDots.test.js updated to import the real dotDiameter rather than restate it.

🤖 Generated with Claude Code

dotStyle scaled a size's preview dot by its VALUE's position in the
row's range. The pen row's widths (2, 4, 8) aren't evenly spaced, so
the middle option landed only a third of the way up — a dot barely
bigger than small, then a big jump to large. The three options read
as two: small and medium looked the same size.

Scale by INDEX instead: every row has exactly three options, so three
evenly-stepped diameters read as small/medium/large regardless of how
far apart the underlying widths happen to be. Extracted dotStyle out
of WhiteboardTools.vue into diagram/sizeDot.js so it has a real test
covering the exact case that broke, instead of the restated copy
sizeDots.test.js used to carry because the .vue file wasn't importable.
Copilot AI lite review requested due to automatic review settings August 20, 2026 14:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vibhavkatre vibhavkatre left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against the source. Merging.

@vibhavkatre
vibhavkatre merged commit f6806d2 into frappe:main Aug 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants