Skip to content

[EuiDatePicker] Prevent onChange from firing out-of-bounds dates on month/year navigation - #9685

Merged
acstll merged 3 commits into
elastic:mainfrom
acstll:worktree-fix+date-picker-month-year-out-of-bounds
Jun 1, 2026
Merged

acstll merged 3 commits into
elastic:mainfrom
acstll:worktree-fix+date-picker-month-year-out-of-bounds

Conversation

@acstll

@acstll acstll commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • What: When minDate or maxDate is set on EuiDatePicker, selecting an out-of-bounds month or year from the dropdown was incorrectly firing onChange with an invalid date.
  • Why: Fixes [EuiDatePicker] Month/year dropdown selection bypasses maxDate/minDate constraint #9659. The internal setSelected method had a branch that called onChange (as a "rejection notification") whenever a disabled/out-of-bounds date was encountered. With adjustDateOnChange: true (the EuiDatePicker default) and accessibleMode enabled, month/year dropdown navigation routes through setSelected, triggering this branch.
  • How: Removed the onChange / onSelect calls from the out-of-bounds branch in setSelected. The calendar view still navigates correctly because setPreSelection is called independently in updateSelection. The selected value stays unchanged until the user explicitly clicks a valid day.

API Changes

N/A

Screenshots

No visual change — behavior fix only.

Impact Assessment

  • 🔴 Breaking changes — What will break?
  • 💅 Visual changes — May impact style overrides
  • 🧪 Test impact — May break functional or snapshot tests
  • 🔧 Hard to integrate — If changes require substantial updates to Kibana

Impact level: 🟢 Low — consumers relying on onChange firing with out-of-bounds dates as a rejection signal will no longer receive those calls. The known workaround of re-validating in onChange remains unaffected.

Release Readiness

  • Documentation: No docs change needed.
  • Figma: No design change.
  • Migration guide: Not a breaking change.
  • Adoption plan: Bug fix.

QA instructions for reviewer

  1. Open any EuiDatePicker story in Storybook.
  2. Add maxDate={moment().endOf('month')} and an onChange that logs the received date.
  3. Open the calendar, open the month dropdown, and select a month beyond maxDate.
  4. Confirm onChange is not called and the selected value remains unchanged.
  5. Repeat with the year dropdown and with minDate.
  6. Confirm that clicking a valid day still fires onChange correctly.

Checklist before marking Ready for Review

  • Filled out all sections above
  • QA: Tested light/dark modes, high contrast, mobile, Chrome/Safari/Edge/Firefox, keyboard-only, screen reader
  • QA: Tested in CodeSandbox and Kibana ([EUI] Test EUI #9685 prevent onChange out-of-bounds dates kibana#271668)
  • QA: Tested docs changes
  • Tests: Added/updated Jest, Cypress, and VRT
  • Changelog: Added changelog entry
  • Breaking changes: Added breaking change label

Reviewer checklist

  • Approved Impact Assessment — Acceptable to merge given the consumer impact.
  • Approved Release Readiness — Docs, Figma, and migration info are sufficient to ship.

@acstll acstll added the skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) label May 28, 2026
@acstll acstll self-assigned this May 28, 2026
@acstll acstll changed the title [EuiDatePicker] prevent onChange from firing out-of-bounds dates on month/year navigation [EuiDatePicker] Prevent onChange from firing out-of-bounds dates on month/year navigation May 28, 2026
@acstll acstll removed the skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) label May 28, 2026
@elasticmachine

Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

History

cc @acstll

@elasticmachine

Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

History

cc @acstll

@acstll

acstll commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

Posting on behalf of Claude (claude-sonnet-4-6 via Claude Code).

Ran a Kibana CI check against this PR using build #449512 on PR elastic/kibana#271668.

The build finished with 2 test failures, neither related to the EUI changes here:

  • FTR Configs Lint and build cleanup #60 — Reporting Functional Tests > Scheduled Reports Flyout > validates required fields: Selenium timeout waiting for [data-test-subj="exportDerivativeFlyout-scheduledReports"]
  • FTR Configs Add React ^16.0 as a peerDependency, add EuiErrorBoundary #198 — management > import objects > .ndjson file > should allow the user to cancel overriding duplicate saved objects: Selenium timeout waiting for [data-test-subj="confirmModalCancelButton"]

Both are unrelated UI timing flakes in Kibana's FTR suite. The date picker fix in this PR is safe from a Kibana CI perspective.

@acstll
acstll marked this pull request as ready for review May 28, 2026 13:19
@acstll
acstll requested a review from a team as a code owner May 28, 2026 13:19
Copilot AI review requested due to automatic review settings May 28, 2026 13:19

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

Fixes a bug in EuiDatePicker where selecting an out-of-bounds month/year from the dropdown navigation fired onChange with an invalid date due to a "rejection notification" branch in the underlying react-datepicker fork's setSelected method.

Changes:

  • Removed the onChange/onSelect calls in the out-of-bounds branch of setSelected in the vendored react-datepicker.
  • Added Jest tests for month and year dropdown navigation with minDate/maxDate.
  • Added changelog entry.

Reviewed changes

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

File Description
packages/eui/src/components/date_picker/react-datepicker/src/index.js Removes the spurious onChange/onSelect calls for out-of-bounds dates
packages/eui/src/components/date_picker/date_picker.test.tsx Adds tests covering month and year dropdown navigation with bounds
packages/eui/changelogs/upcoming/9685.md Adds changelog entry for the fix

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

@weronikaolejniczak weronikaolejniczak 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.

LGTM 🟢 Thanks for the fix, Arturo!

@acstll
acstll merged commit 7c8fcb4 into elastic:main Jun 1, 2026
2 checks passed
JasonStoltz pushed a commit to elastic/kibana that referenced this pull request Jun 24, 2026
## Dependency updates

`@elastic/eui` - v116.2.0 ⏩ v116.3.1
`@elastic/eslint-plugin-eui` - v2.13.0 ⏩ v2.14.0

## Package updates

### `@elastic/eui`
[v116.3.1](https://github.com/elastic/eui/blob/main/packages/eui/changelogs/CHANGELOG_2026.md)

**Bug fixes**

- Fixed `EuiTableHeaderCell` and `EuiTableHeaderCellCheckbox` throwing
an error in Jest test environments due to static mocking of
`useGeneratedHtmlId` by generating a stable, unique key with `uuidv4`
([#9698](elastic/eui#9698))
- Fixed an issue where the tooltip anchor wrapper in `EuiAvatar` did not
have the same `border-radius` applied as the avatar itself.
([#9697](elastic/eui#9697))


### `@elastic/eui`
[v116.3.0](https://github.com/elastic/eui/blob/main/packages/eui/changelogs/CHANGELOG_2026.md)

- Added `EuiBanner` component
([#9673](elastic/eui#9673))
- Replaced native browser `title` attributes with `EuiToolTip` across
the following components for consistent tooltips:
([#9643](elastic/eui#9643))
  - `EuiAvatar`
  - `EuiBasicTable`
  - `EuiBreadcrumbs`
  - `EuiComboBox`
  - `EuiDataGrid`
  - `EuiAutoRefresh`
  - `EuiSuperDatePicker`
  - `EuiFieldPassword`
  - `EuiMarkdownEditor`
  - `EuiPagination`
  - `EuiSearchBar`
  - `EuiSelectable`
  - `EuiTextTruncate`
- Extended `EuiToolTip`'s `display` prop to support `"flex"`
([#9643](elastic/eui#9643))
- Added experimental support for sticky headers in `EuiTable`,
`EuiBasicTable` and `EuiInMemoryTable`
([#9682](elastic/eui#9682))

**Bug fixes**

- Fixed `direction="row"` not applying on `EuiSplitPanel.Outer` when
`onClick` was set. ([#9693](elastic/eui#9693))
- Fixed `EuiDatePicker` firing `onChange` with an out-of-bounds date
when navigating to a month or year via the dropdowns while `minDate` or
`maxDate` is set ([#9685](elastic/eui#9685))
- Fixed a visual issue on `EuiPanel` where panels with `onClick` would
render with a `height` difference of `1px`.
([#9694](elastic/eui#9694))
- Fixed an issue in `EuiSelectable` and `EuiComboBox` where interactive
content in group labels wasn't clickable due to overlapping content.
([#9678](elastic/eui#9678))
### `@elastic/eslint-plugin-eui`
[v2.14.0](https://github.com/elastic/eui/blob/main/packages/eslint-plugin/changelogs/CHANGELOG_2026.md)

- Removed auto-fix from `tooltip-button-icon-wrap` rule
([#9695](elastic/eui#9695))

---------

Co-authored-by: Tomasz Kajtoch <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Lene Gadewoll <[email protected]>
patrykkopycinski pushed a commit to patrykkopycinski/kibana that referenced this pull request Aug 5, 2026
## Dependency updates

`@elastic/eui` - v116.2.0 ⏩ v116.3.1
`@elastic/eslint-plugin-eui` - v2.13.0 ⏩ v2.14.0

## Package updates

### `@elastic/eui`
[v116.3.1](https://github.com/elastic/eui/blob/main/packages/eui/changelogs/CHANGELOG_2026.md)

**Bug fixes**

- Fixed `EuiTableHeaderCell` and `EuiTableHeaderCellCheckbox` throwing
an error in Jest test environments due to static mocking of
`useGeneratedHtmlId` by generating a stable, unique key with `uuidv4`
([elastic#9698](elastic/eui#9698))
- Fixed an issue where the tooltip anchor wrapper in `EuiAvatar` did not
have the same `border-radius` applied as the avatar itself.
([elastic#9697](elastic/eui#9697))


### `@elastic/eui`
[v116.3.0](https://github.com/elastic/eui/blob/main/packages/eui/changelogs/CHANGELOG_2026.md)

- Added `EuiBanner` component
([elastic#9673](elastic/eui#9673))
- Replaced native browser `title` attributes with `EuiToolTip` across
the following components for consistent tooltips:
([elastic#9643](elastic/eui#9643))
  - `EuiAvatar`
  - `EuiBasicTable`
  - `EuiBreadcrumbs`
  - `EuiComboBox`
  - `EuiDataGrid`
  - `EuiAutoRefresh`
  - `EuiSuperDatePicker`
  - `EuiFieldPassword`
  - `EuiMarkdownEditor`
  - `EuiPagination`
  - `EuiSearchBar`
  - `EuiSelectable`
  - `EuiTextTruncate`
- Extended `EuiToolTip`'s `display` prop to support `"flex"`
([elastic#9643](elastic/eui#9643))
- Added experimental support for sticky headers in `EuiTable`,
`EuiBasicTable` and `EuiInMemoryTable`
([elastic#9682](elastic/eui#9682))

**Bug fixes**

- Fixed `direction="row"` not applying on `EuiSplitPanel.Outer` when
`onClick` was set. ([elastic#9693](elastic/eui#9693))
- Fixed `EuiDatePicker` firing `onChange` with an out-of-bounds date
when navigating to a month or year via the dropdowns while `minDate` or
`maxDate` is set ([elastic#9685](elastic/eui#9685))
- Fixed a visual issue on `EuiPanel` where panels with `onClick` would
render with a `height` difference of `1px`.
([elastic#9694](elastic/eui#9694))
- Fixed an issue in `EuiSelectable` and `EuiComboBox` where interactive
content in group labels wasn't clickable due to overlapping content.
([elastic#9678](elastic/eui#9678))
### `@elastic/eslint-plugin-eui`
[v2.14.0](https://github.com/elastic/eui/blob/main/packages/eslint-plugin/changelogs/CHANGELOG_2026.md)

- Removed auto-fix from `tooltip-button-icon-wrap` rule
([elastic#9695](elastic/eui#9695))

---------

Co-authored-by: Tomasz Kajtoch <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Lene Gadewoll <[email protected]>
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.

[EuiDatePicker] Month/year dropdown selection bypasses maxDate/minDate constraint

4 participants