Skip to content

Sd/fix invalid date issue#1

Open
shatd wants to merge 1 commit into
raminious:masterfrom
shatd:sd/fix-invalid-date-issue
Open

Sd/fix invalid date issue#1
shatd wants to merge 1 commit into
raminious:masterfrom
shatd:sd/fix-invalid-date-issue

Conversation

@shatd

@shatd shatd commented Jun 18, 2026

Copy link
Copy Markdown
image Screen Shot 2026-06-18 at 7 45 11 PM

Hi Ramin,

Fix: Prevent crashes when selecting extremely long date ranges

Problem

When users attempt to select extremely long date ranges (e.g., moving the calendar too far), the app crashes with invalid date objects ({from: Invalid Date, to: Invalid Date}), resulting in NaN values in labels and broken UI state.

Root Cause

  • Date calculations in slider utilities didn't validate input dates before diffing
  • Missing guards in calendar popover range extension logic
  • No fallback handling for invalid date propagation in UI rendering

Solution

  • Created normalizeDateRange() shared helper to safely normalize and validate date ranges
  • Applied defensive guards in createSliderValues and deriveSelectionFromLayout to clamp invalid dates
  • Updated date label rendering and selection display to handle invalid dates gracefully
  • Fixed numeric safeguards to prevent NaN propagation (e.g., count - 1 division, Number.isFinite() checks)

Changes

  • ✅ Added normalize-date-range.ts utility
  • ✅ Updated slider value calculations with date validation
  • ✅ Added safe fallbacks in label rendering
  • ✅ Guards against invalid date operations in calendar popover

Testing

Build passes without errors. Date range selection now remains stable even with extreme calendar movements.

@shatd shatd force-pushed the sd/fix-invalid-date-issue branch from e45ca19 to 50640ed Compare June 18, 2026 14:18
@raminious

Copy link
Copy Markdown
Owner

Hi @shatd
I appreciate the PR. Before proceeding with the merge, could you please provide the steps to reproduce the bug so that I can understand the issue?

@shatd

shatd commented Jun 23, 2026

Copy link
Copy Markdown
Author

Hi @raminious ,
Screen Shot 2026-06-23 at 9 09 39 AM
Screen Shot 2026-06-23 at 9 12 54 AM
image

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.

2 participants