Skip to content

fix(ui): implement exact absolute coordinate alignment for month labels on heatmap#402

Merged
Priyanshu-byte-coder merged 1 commit into
Priyanshu-byte-coder:mainfrom
Visaka123:main
May 20, 2026
Merged

fix(ui): implement exact absolute coordinate alignment for month labels on heatmap#402
Priyanshu-byte-coder merged 1 commit into
Priyanshu-byte-coder:mainfrom
Visaka123:main

Conversation

@Visaka123
Copy link
Copy Markdown
Contributor

Summary

This PR addresses and resolves structural alignment anomalies affecting the **ContributionHeatmap** month timeline headers. The original implementation relied on fluid layout constraints and implicit element distributions, leading to rendering drift and text truncation when months initiated mid-week or crossed chronological year boundaries.

This refactor establishes a deterministic positioning matrix that maps text headers directly to the exact grid track indices utilized by the underlying canvas architecture.

Closes #249

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor / code cleanup (non-breaking optimization)

Changes Made

1. Chronological State Transition Engine

  • Replaced unstable day-of-month fallback matching (cell.date.getDate() === 1) with an itemized matrix traversal check utilizing a strict unique tracking set (!seenMonths.has(monthKey)).
  • This ensures that a month column anchor is initialized the absolute instant a week track encounters the first valid day of a new month, completely normalizing rendering behaviors across tricky mid-week switches.

2. Matrix Coordinate Harmonization

  • Migrated the header row away from standard CSS flex/grid track distributions to prevent dynamic column compression.
  • Established an identical coordinate identity rule where each label's horizontal positioning is strictly computed via the canvas baseline formula:
    LABEL_WIDTH + weekIndex * (CELL_SIZE + CELL_GAP)
  • This binds text anchors directly to the starting pixel coordinate of their matching column tracks.

3. Allocation and Truncation Guard

  • Applied width: "auto" and min-width: "max-content" layers to the absolute layout blocks to eliminate multi-column tracking collisions. Short-span labels (e.g., Jun, Jul) bleed naturally into subsequent empty tracking headers without visual string truncation (...).
  • Extracted and memoized the Intl.DateTimeFormat instance globally. This removes redundant engine instantiations inside the raw loop iterations, significantly reducing garbage collection overhead and main-thread execution time.
  • Cleaned up active layout tracing logs (console.log) to keep production runtime terminal spaces pristine.

How to Test

  1. Initialize the local development environment (npm run dev).
  2. Verify that month markers left-align flawlessly with the exact geometric boundary of their corresponding grid track columns.
  3. Inspect boundary edge-cases (specifically January crossing the year boundary line and April/May mid-week starting points) to confirm mathematical alignment.
  4. Verify through the browser inspection console that zero infinite layout re-render loops or network rate-limit errors occur.

Screenshots

image

Checklist

  • Linked issue in summary
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Self-reviewed the diff

@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

@Visaka123 is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Thanks for your first PR on DevTrack! 🎉

A maintainer will review it within 48 hours. While you wait:

  • Make sure CI is passing (type-check + lint)
  • Double-check the PR description is filled out and the issue is linked
  • Feel free to ask questions in Discussions if you need help

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

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

Fix is correct — switching from grid-based to absolute positioning for month labels solves the alignment problem. The gridRow reindex, setLastUpdated moved to .then(), and totalGridWidth calculation are all sound. One note for follow-up: clean up the hyperbolic comments ("100% MATHEMATICALLY PRECISE...") — not production style. Merging.

@Priyanshu-byte-coder Priyanshu-byte-coder added level:intermediate GSSoC: Intermediate difficulty (35 pts) type:bug GSSoC type bonus: bug fix gssoc:approved GSSoC: PR approved for scoring labels May 20, 2026
@Priyanshu-byte-coder Priyanshu-byte-coder merged commit 5ce342d into Priyanshu-byte-coder:main May 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC: PR approved for scoring level:intermediate GSSoC: Intermediate difficulty (35 pts) type:bug GSSoC type bonus: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Contribution heatmap month labels misalign when year starts mid-column

2 participants