Skip to content

feat(WebChartReportViewer): use DateInput component with calendar for custom date range#134

Merged
garrity-miepub merged 2 commits into
mainfrom
update/webChartReportViewer-date-input
Mar 11, 2026
Merged

feat(WebChartReportViewer): use DateInput component with calendar for custom date range#134
garrity-miepub merged 2 commits into
mainfrom
update/webChartReportViewer-date-input

Conversation

@garrity-miepub

@garrity-miepub garrity-miepub commented Mar 11, 2026

Copy link
Copy Markdown
Collaborator

Updating the WebChartReportViewer to use the date input (date picker) component. Also renaming this particular variant of the WebChartReportViewer from date picker to ReportTimeRange - its more appropriate.

report-time-range.mov

Copilot AI review requested due to automatic review settings March 11, 2026 22:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates WebChartReportViewer to use the shared DateInput (calendar-enabled) for custom date ranges, aligning report date controls with the design system’s date picker behavior.

Changes:

  • Replaced native Input type="date" controls with DateInput in the report viewer toolbar date range.
  • Replaced native Input type="date" controls with DateInput in ReportDatePicker’s custom range mode.
  • Added local formatting helpers to convert between MM/DD/YYYY (DateInput) and YYYY-MM-DD (callbacks).

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

Comment thread src/components/WebChartReportViewer/WebChartReportViewer.tsx Outdated
Comment thread src/components/WebChartReportViewer/WebChartReportViewer.tsx Outdated
Comment thread src/components/WebChartReportViewer/WebChartReportViewer.tsx Outdated
Comment thread src/components/WebChartReportViewer/WebChartReportViewer.tsx Outdated
Comment thread src/components/WebChartReportViewer/WebChartReportViewer.tsx Outdated
Comment thread src/components/WebChartReportViewer/WebChartReportViewer.tsx Outdated
- Fix timezone bug by using Luxon to parse YYYY-MM-DD as local date
- Only propagate date changes when input is valid (prevents keystroke thrashing)
- Extract shared date helpers to src/utils/date.ts (dateToDisplayFormat, displayFormatToDateString)
- Rename ReportDatePicker to ReportTimeRange with deprecated alias
- Fix comment wording (YYYY-MM-DD, not ISO timestamp)
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 11, 2026

Copy link
Copy Markdown

Deploying ui with  Cloudflare Pages  Cloudflare Pages

Latest commit: bd59cbb
Status: ✅  Deploy successful!
Preview URL: https://d3ccbe93.ui-6d0.pages.dev
Branch Preview URL: https://update-webchartreportviewer.ui-6d0.pages.dev

View logs

@garrity-miepub garrity-miepub marked this pull request as ready for review March 11, 2026 23:45
Copilot AI review requested due to automatic review settings March 11, 2026 23:45
@garrity-miepub garrity-miepub merged commit 89bd8bb into main Mar 11, 2026
11 of 12 checks passed
@garrity-miepub garrity-miepub deleted the update/webChartReportViewer-date-input branch March 11, 2026 23:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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


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

Comment thread src/utils/date.ts
const [year, month, day] = date.split('-').map(Number);
dt = DateTime.local(year, month, day);
} else {
// Try parsing as full ISO or other format

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

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

The inline comment says “full ISO or other format”, but the implementation only attempts DateTime.fromISO(...). Either update the wording to match what’s actually supported, or add parsing for the additional formats you expect here.

Suggested change
// Try parsing as full ISO or other format
// Try parsing as an ISO datetime string in the local timezone

Copilot uses AI. Check for mistakes.
Comment on lines +155 to +161
onDateRangeChange?.(displayFormatToDateString(value), dateRange?.end || new Date());
}
};

const handleEndDateChange = (value: string) => {
if (isValidDate(value)) {
onDateRangeChange?.(dateRange?.start || new Date(), displayFormatToDateString(value));

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

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

Using || new Date() here will treat empty-string dates (""), which are valid string values for this API, as falsy and silently replace them with new Date(). Prefer nullish coalescing (??) so only null/undefined fall back, or explicitly handle the empty-string case if that's intended.

Suggested change
onDateRangeChange?.(displayFormatToDateString(value), dateRange?.end || new Date());
}
};
const handleEndDateChange = (value: string) => {
if (isValidDate(value)) {
onDateRangeChange?.(dateRange?.start || new Date(), displayFormatToDateString(value));
onDateRangeChange?.(displayFormatToDateString(value), dateRange?.end ?? new Date());
}
};
const handleEndDateChange = (value: string) => {
if (isValidDate(value)) {
onDateRangeChange?.(dateRange?.start ?? new Date(), displayFormatToDateString(value));

Copilot uses AI. Check for mistakes.
Comment on lines +155 to +161
onDateRangeChange?.(displayFormatToDateString(value), dateRange?.end || new Date());
}
};

const handleEndDateChange = (value: string) => {
if (isValidDate(value)) {
onDateRangeChange?.(dateRange?.start || new Date(), displayFormatToDateString(value));

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

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

Same issue as above: || new Date() will override an intentionally empty-string dateRange.start with today’s date. Use ?? (or explicitly handle empty string) to avoid changing meaning for consumers that represent “unset” with "".

Suggested change
onDateRangeChange?.(displayFormatToDateString(value), dateRange?.end || new Date());
}
};
const handleEndDateChange = (value: string) => {
if (isValidDate(value)) {
onDateRangeChange?.(dateRange?.start || new Date(), displayFormatToDateString(value));
onDateRangeChange?.(displayFormatToDateString(value), dateRange?.end ?? new Date());
}
};
const handleEndDateChange = (value: string) => {
if (isValidDate(value)) {
onDateRangeChange?.(dateRange?.start ?? new Date(), displayFormatToDateString(value));

Copilot uses AI. Check for mistakes.
Comment on lines +460 to +466
onChange?.(displayFormatToDateString(value), endDate || new Date());
}
};

const handleEndChange = (value: string) => {
if (isValidDate(value)) {
onChange?.(startDate || new Date(), displayFormatToDateString(value));

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

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

Using endDate || new Date() will treat an empty-string end date as falsy and replace it with new Date(). Prefer endDate ?? new Date() (or explicitly handle "") so only missing values fall back.

Suggested change
onChange?.(displayFormatToDateString(value), endDate || new Date());
}
};
const handleEndChange = (value: string) => {
if (isValidDate(value)) {
onChange?.(startDate || new Date(), displayFormatToDateString(value));
onChange?.(displayFormatToDateString(value), endDate ?? new Date());
}
};
const handleEndChange = (value: string) => {
if (isValidDate(value)) {
onChange?.(startDate ?? new Date(), displayFormatToDateString(value));

Copilot uses AI. Check for mistakes.
Comment on lines +460 to +466
onChange?.(displayFormatToDateString(value), endDate || new Date());
}
};

const handleEndChange = (value: string) => {
if (isValidDate(value)) {
onChange?.(startDate || new Date(), displayFormatToDateString(value));

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

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

Using startDate || new Date() will treat an empty-string start date as falsy and replace it with new Date(). Prefer startDate ?? new Date() (or explicitly handle "") so consumers can represent “unset” dates without them being coerced.

Suggested change
onChange?.(displayFormatToDateString(value), endDate || new Date());
}
};
const handleEndChange = (value: string) => {
if (isValidDate(value)) {
onChange?.(startDate || new Date(), displayFormatToDateString(value));
onChange?.(displayFormatToDateString(value), endDate ?? new Date());
}
};
const handleEndChange = (value: string) => {
if (isValidDate(value)) {
onChange?.(startDate ?? new Date(), displayFormatToDateString(value));

Copilot uses AI. Check for mistakes.
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