Skip to content

Conversation

@Mash707
Copy link
Contributor

@Mash707 Mash707 commented Jan 12, 2026

Towards #11952

Summary by CodeRabbit

  • New Features

    • Added a reusable date range picker example component with start/end inputs and automatic range validation.
  • Documentation

    • Date picker docs now reference external TypeScript example files instead of embedding inline code.
    • Wizard and date picker documentation code blocks converted to TypeScript for consistency.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 12, 2026

Walkthrough

Extracted an inline DatePicker range example into an external TypeScript component and updated documentation code fences from JavaScript to TypeScript.

Changes

Cohort / File(s) Summary
DatePicker demo extraction
packages/react-core/src/demos/DatePicker/DatePicker.md, packages/react-core/src/demos/DatePicker/examples/DatePickerRange.tsx
Removed an inline 47-line JS DateRangePicker example from the Markdown and replaced it with a ts file="./examples/DatePickerRange.tsx" reference. Added DatePickerRange component implementing start/end date state, validation, conditional enabling of the end picker, and date formatting.
Wizard documentation language update
packages/react-core/src/demos/Wizard/WizardDemo.md
Changed six fenced code blocks from js to ts for multiple Wizard examples; no functional changes.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant DatePickerRange
  participant StartPicker
  participant EndPicker

  User->>DatePickerRange: open demo
  DatePickerRange->>StartPicker: render (from,state)
  DatePickerRange->>EndPicker: render (to,state, disabled if no from)
  User->>StartPicker: select start date
  StartPicker-->>DatePickerRange: onFromChange(date)
  DatePickerRange->>EndPicker: enable and set to = nextDay(date) if valid
  User->>EndPicker: select end date
  EndPicker-->>DatePickerRange: onToChange(date) (validated against from)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • lboehling
  • thatblindgeye
  • nicolethoen
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: updating documentation tags and examples from JavaScript to TypeScript for the Wizard and DatePicker components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b73e272 and 80d003b.

📒 Files selected for processing (1)
  • packages/react-core/src/demos/DatePicker/examples/DatePickerRange.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/react-core/src/demos/DatePicker/examples/DatePickerRange.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build, test & deploy
  • GitHub Check: Build

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In @packages/react-core/src/demos/DatePicker/examples/DatePickerRange.tsx:
- Around line 1-4: The component DatePickerRange uses the
React.FunctionComponent type but React is not imported; add an import for React
(e.g., import React from 'react') at the top of the file or replace the explicit
React-prefixed type with a locally imported type (e.g., import {
FunctionComponent } from 'react' and use FunctionComponent) so the
React.FunctionComponent annotation resolves and TypeScript compiles.
- Around line 11-19: onFromChange mutates the incoming date parameter via
date.setDate(...), causing side effects; fix by cloning the date before
modifying and using that clone when calling setFrom and when computing the
next-day value for setTo (e.g., create a new Date(date) or Date.from copy),
preserve the isValidDate check, call setFrom with the cloned date, increment the
clone for yyyyMMddFormat, and avoid mutating the original parameter so callers
are not affected.
- Around line 5-6: Add explicit type parameters to the two useState hooks so
their state types match what you pass to the setters: annotate the `from` state
in the DatePickerRange example as Date | undefined (used with `setFrom`
receiving a Date) and annotate the `to` state as string | undefined (used with
`setTo` receiving a string); update the `const [from, setFrom] = useState()` and
`const [to, setTo] = useState()` lines to include these type arguments so
TypeScript infers the correct types for `setFrom` and `setTo`.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 097dae1 and b73e272.

📒 Files selected for processing (3)
  • packages/react-core/src/demos/DatePicker/DatePicker.md
  • packages/react-core/src/demos/DatePicker/examples/DatePickerRange.tsx
  • packages/react-core/src/demos/Wizard/WizardDemo.md
🧰 Additional context used
🧬 Code graph analysis (1)
packages/react-core/src/demos/DatePicker/examples/DatePickerRange.tsx (4)
packages/react-core/src/helpers/datetimeUtils.ts (1)
  • isValidDate (4-4)
packages/react-core/src/components/DatePicker/DatePicker.tsx (2)
  • yyyyMMddFormat (89-93)
  • DatePicker (357-357)
packages/react-core/src/layouts/Split/Split.tsx (1)
  • Split (17-39)
packages/react-core/src/layouts/Split/SplitItem.tsx (1)
  • SplitItem (15-28)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build
  • GitHub Check: Build, test & deploy
🔇 Additional comments (3)
packages/react-core/src/demos/Wizard/WizardDemo.md (1)

17-42: LGTM!

The language specifier updates from js to ts are appropriate since the referenced files have .tsx extensions. This improves documentation consistency.

packages/react-core/src/demos/DatePicker/examples/DatePickerRange.tsx (1)

21-45: LGTM!

The onToChange handler correctly validates the date before updating state, and the JSX structure properly uses PatternFly's Split layout components with appropriate props for the date range picker behavior.

packages/react-core/src/demos/DatePicker/DatePicker.md (1)

16-17: LGTM!

The update correctly references the new external TypeScript file, aligning with the PR objective of migrating examples from JavaScript to TypeScript.

Comment on lines +11 to +19
const onFromChange = (_event: React.MouseEvent<HTMLElement>, _value: string, date: Date) => {
setFrom(new Date(date));
if (isValidDate(date)) {
date.setDate(date.getDate() + 1);
setTo(yyyyMMddFormat(date));
} else {
setTo('');
}
};
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Avoid mutating the input date parameter.

Line 14 mutates the date object passed as a parameter using setDate(). This side effect modifies the caller's date object, which can cause unexpected behavior. Create a copy before modifying.

🔧 Proposed fix
  const onFromChange = (_event: React.MouseEvent<HTMLElement>, _value: string, date: Date) => {
    setFrom(new Date(date));
    if (isValidDate(date)) {
-      date.setDate(date.getDate() + 1);
-      setTo(yyyyMMddFormat(date));
+      const nextDay = new Date(date);
+      nextDay.setDate(nextDay.getDate() + 1);
+      setTo(yyyyMMddFormat(nextDay));
    } else {
      setTo('');
    }
  };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const onFromChange = (_event: React.MouseEvent<HTMLElement>, _value: string, date: Date) => {
setFrom(new Date(date));
if (isValidDate(date)) {
date.setDate(date.getDate() + 1);
setTo(yyyyMMddFormat(date));
} else {
setTo('');
}
};
const onFromChange = (_event: React.MouseEvent<HTMLElement>, _value: string, date: Date) => {
setFrom(new Date(date));
if (isValidDate(date)) {
const nextDay = new Date(date);
nextDay.setDate(nextDay.getDate() + 1);
setTo(yyyyMMddFormat(nextDay));
} else {
setTo('');
}
};
🤖 Prompt for AI Agents
In @packages/react-core/src/demos/DatePicker/examples/DatePickerRange.tsx around
lines 11 - 19, onFromChange mutates the incoming date parameter via
date.setDate(...), causing side effects; fix by cloning the date before
modifying and using that clone when calling setFrom and when computing the
next-day value for setTo (e.g., create a new Date(date) or Date.from copy),
preserve the isValidDate check, call setFrom with the cloned date, increment the
clone for yyyyMMddFormat, and avoid mutating the original parameter so callers
are not affected.

@patternfly-build
Copy link
Collaborator

patternfly-build commented Jan 12, 2026

Copy link
Contributor

@dlabaj dlabaj left a comment

Choose a reason for hiding this comment

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

LGTM

@nicolethoen nicolethoen merged commit 38232ee into patternfly:main Jan 12, 2026
14 checks passed
@patternfly-build
Copy link
Collaborator

Your changes have been released in:

  • @patternfly/react-code-editor@6.5.0-prerelease.30
  • @patternfly/react-core@6.5.0-prerelease.28
  • @patternfly/react-docs@7.5.0-prerelease.31
  • @patternfly/react-drag-drop@6.5.0-prerelease.28
  • demo-app-ts@6.5.0-prerelease.56
  • @patternfly/react-table@6.5.0-prerelease.28
  • @patternfly/react-templates@6.5.0-prerelease.28

Thanks for your contribution! 🎉

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.

6 participants