Skip to content

fix(datetime): scope month values bounds to year - #31490

Open
breken-ai wants to merge 1 commit into
ionic-team:mainfrom
breken-ai:fix/datetime-month-values-year
Open

breken-ai wants to merge 1 commit into
ionic-team:mainfrom
breken-ai:fix/datetime-month-values-year

Conversation

@breken-ai

Copy link
Copy Markdown

Issue number: N/A (no existing issue; repro below)


What is the current behavior?

When monthValues is set, getMonthColumnData (core/src/components/datetime/utils/data.ts) filters the month wheel by min.month and max.month in every year, not only in the min/max year. The branch without monthValues already checks minParts.year === year / maxParts.year === year.

Example: <ion-datetime prefer-wheel="true" min="2020-06-01" month-values="1,3,5,7,9,11">. In 2024, the month wheel shows only July, September and November. January, March and May are missing even though every date in 2024 is after min. The same happens with max: max="2025-04-30" hides May to November in 2024 and earlier years.

What is the new behavior?

  • The min month only applies when the displayed year is the min year, and the max month only when it is the max year, the same as without monthValues.

New unit tests for getMonthColumnData() in data.spec.ts cover min, max, and a check that the result matches the months shown without monthValues.

Red on main (879e91d):

● getMonthColumnData() › should apply the max month only in the max year when monthValues is set
● getMonthColumnData() › should apply the min month only in the min year when monthValues is set
● getMonthColumnData() › should match the months shown when monthValues is not set

Green with the fix: npx stencil test --spec -- src/components/datetime/test/ passes 116/116. eslint, prettier --check and tsc --noEmit -p tsconfig.json are clean.

Does this introduce a breaking change?

  • Yes
  • No

Other information

This fix was found and written with an AI coding assistant (Claude Code); the red/green runs above are from this branch.

🤖 Generated with Claude Code

With monthValues set, getMonthColumnData filtered months by the min
and max month in every year. With min="2020-06" and monthValues set,
January to May were missing from every later year too. The branch
without monthValues already checks the year.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@breken-ai
breken-ai requested a review from a team as a code owner September 26, 2026 02:47
@breken-ai
breken-ai requested a review from ShaneK September 26, 2026 02:47
@vercel

vercel Bot commented Sep 26, 2026

Copy link
Copy Markdown

@breken-ai is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the package: core @ionic/core package label Sep 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant