Skip to content

fix(settings): order parseSettings before initBuckets; dedupe color defaults#246

Merged
Demonkratiy merged 1 commit into
microsoft:mainfrom
Demonkratiy:fix/gradient-middle-cleanup
Jun 15, 2026
Merged

fix(settings): order parseSettings before initBuckets; dedupe color defaults#246
Demonkratiy merged 1 commit into
microsoft:mainfrom
Demonkratiy:fix/gradient-middle-cleanup

Conversation

@Demonkratiy

Copy link
Copy Markdown
Contributor

Summary

Small follow-up cleanups after #221 (gradient middle feature).

Changes

  • Run parseSettings() before initBuckets() in update(). parseSettings() can flip enableColorbrewer / activateGradientMiddle (e.g. in high-contrast mode), so running it first ensures bucket constraints (buckets.options.min/maxValue, CurrentBucketCount) match the final rendered mode instead of being stuck at the pre-parse Colorbrewer limits.
  • Dedupe stroke / textColor defaults into GeneralSettings.DefaultStroke / GeneralSettings.DefaultTextColor constants, referenced from both GeneralSettings and parseSettings() to avoid future drift.
  • Add a high-contrast regression test that drives the full update() flow and asserts the post-parse bucket constraints (minValue = 1, maxValue = 18). This test fails on the old initBuckets → parseSettings order and passes on the new one, guarding the fix against future reordering.

Notes

  • Out of scope: the start/end Colorbrewer write-back rework (single-source-of-truth color sync via persistProperties) will be a separate PR.

Validation

  • eslint src/ clean
  • 71/71 unit tests pass
  • Regression test verified to fail on the previous ordering and pass on the new one

…match rendered mode

- dedupe stroke/textColor defaults into GeneralSettings constants

- add high-contrast regression test guarding the init order
Copilot AI review requested due to automatic review settings June 15, 2026 07:27

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.

Pull request overview

This PR is a focused follow-up to the gradient-middle work (#221) that fixes a settings initialization ordering issue affecting high-contrast rendering, and centralizes a couple of default color constants to avoid drift.

Changes:

  • Reorders update() to run parseSettings() before initBuckets() so bucket min/max constraints are computed from the final (post-parse) mode, particularly in high-contrast mode.
  • Deduplicates default stroke and textColor values into GeneralSettings.DefaultStroke / GeneralSettings.DefaultTextColor and reuses them in both settings initialization and parseSettings().
  • Adds a high-contrast regression test that drives the full update() flow and asserts bucket constraint min/max values match the non-colorbrewer limits.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
test/visualTest.ts Adds a high-contrast regression test validating post-parse bucket min/max constraints.
src/visual.ts Reorders settings initialization so parseSettings() runs before initBuckets().
src/settings.ts Introduces shared constants for default stroke/text colors and uses them in GeneralSettings.
src/heatmapUtils.ts Uses GeneralSettings default color constants in parseSettings() to avoid duplicated literals.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Demonkratiy Demonkratiy merged commit 1e9bd7f into microsoft:main Jun 15, 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