Repository navigation
Description
Reported by
Describe the bug
When maxDate is passed to EuiDatePicker, selecting a month from the dropdown that would place the current day beyond maxDate fires onChange with the out-of-bounds date, which was presumably intended to notify consumers of a rejected selection:
eui/packages/eui/src/components/date_picker/react-datepicker/src/index.js
Lines 476 to 486 in e708b6f
| setSelected = (date, event, keepInput) => { | |
| let changedDate = date; | |
| if (changedDate !== null && isDayDisabled(changedDate, this.props)) { | |
| if (isOutOfBounds(changedDate, this.props)) { | |
| this.props.onChange(date, event); | |
| this.props.onSelect(changedDate, event); | |
| } | |
| return; | |
| } |
The same issue applies to minDate and to year dropdown selection.
Impact and severity
Potentially incorrect API calls and wrong data shown to the end-user. The impact and severity are medium.
| File | maxDate |
minDate |
onChange |
Bounds check in onChange |
|---|---|---|---|---|
| ml/.../create_calendar.tsx | ✓ | ✓ | ✓ | ✗ |
| ml/.../time_range_picker.tsx | ✓ | ✗ | ✓ | ✗ |
| ml/.../time_range_selector.js | ✓ | ✓ | ✓ | ✗ |
| ml/.../new_event_modal.js | ✗ | ✗ | ✓ | ✓ (cross-date only) |
| ml/.../custom_time_range_picker.tsx | ✗ | ✗ | ✓ | ✗ |
| ml/.../datafeed_chart_flyout.tsx | ✗ | ✗ | ✓ | ✗ |
| fleet/.../go_to_date.tsx | ✓ | ✗ | ✓ | ✗ |
| fleet/.../agent_upgrade_modal/index.tsx | ✗ | ✓ | ✓ | ✗ |
| maintenance_windows/.../date_picker_range_field.tsx | ✗ | ✓ | ✓ | ✓ (cross-date only) |
| triggers_actions_ui/.../scheduler.tsx | ✗ | ✓ | ✓ | ✗ (isInvalid UI only) |
| triggers_actions_ui/.../recurrence_scheduler/index.tsx | ✗ | ✓ | ✓ | ✗ |
| response-ops/.../snooze_duration_picker.tsx | ✗ | ✓ | ✓ | ✗ |
| response-ops/.../rule_actions_alerts_filter_timeframe.tsx | ✗ | ✗ | ✓ | ✗ |
| security_solution/.../protection_updates_layout.tsx | ✓ | ✓ | ✓ | ✓ |
| security_solution/.../health_interval_filter.tsx | ✓ | ✓ | ✓ | ✗ |
| security_solution/.../expire_time/index.tsx | ✗ | ✓ | ✓ | ✓ (past check only) |
| security_solution/.../threat_intelligence_...range_picker.tsx | ✗ | ✗ | ✓ | ✓ (cross-date only) |
| security_solution/.../schedule_bulk_action_modal/index.tsx | ✗ | ✗ | ✓ | ✗ |
| infra/.../fixed_datepicker.tsx | ✗ | ✗ | ✗ | N/A (styled wrapper) |
| infra/.../waffle_time_controls.tsx | ✗ | ✗ | ✓ | ✗ |
| observability/.../annotation_range.tsx | ✗ | ✗ | ✓ | ✗ |
| observability/.../date_range_picker.tsx | ✗ | ✗ | ✓ | ✗ |
| slo/.../purge_rollup_confirmation_modal.tsx | ✗ | ✗ | ✓ | ✗ |
| agent_builder/.../esql_param_value_input.tsx | ✗ | ✗ | ✓ | ✗ |
| agent_builder/.../test_tools.tsx | ✗ | ✗ | ✓ | ✗ |
| cases/.../date_picker.tsx | ✗ | ✗ | ✓ | ✗ |
| es_ui_shared/.../date_picker_field.tsx | ✗ | ✗ | ✓ | ✗ |
| kbn-event-annotation-components/.../range_annotation_panel.tsx | ✗ | ✗ | ✓ | ✗ |
| kbn-esql-editor/.../esql_editor.tsx | ✗ | ✗ | ✓ | ✗ |
Summary
| Metric | Count |
|---|---|
| Total usages | 29 |
With maxDate |
6 |
With minDate |
10 |
With maxDate or minDate |
12 |
With explicit maxDate/minDate bounds check in onChange |
1 |
| Relying entirely on EUI to enforce bounds | 11 |
A known workaround is to re-validate the received date against maxDate/minDate inside the onChange handler (example). This duplicates the constraint that the component already accepts as a prop but is an acceptable workaround on consumer side in the meantime.
See also: elastic/kibana#180788
Environment and versions
- EUI version: latest
- React version: -
- Kibana version (if applicable): -
- Browser: -
- Operating System: -
Minimum reproducible sandbox
Starting from any EuiDatePicker example on https://eui.elastic.co/, add:
<EuiDatePicker
selected={selected}
maxDate={moment().endOf('month')} // e.g. end of current month
onChange={(date) => {
console.log('onChange fired:', date?.format());
setSelected(date);
}}
/>Open the month dropdown and select any month beyond the current one. Observe onChange is called with a date past maxDate, logged in the console.
To Reproduce
- Render an
EuiDatePickerwith amaxDateset to any date in the past or near future and anonChangethat logs its argument. - Open the calendar popover.
- Open the month dropdown and select a month that would place the currently selected day beyond
maxDate(e.g. ifmaxDateis end of May and the selected day is the 15th, pick August). - Observe that
onChangefires with August 15, a date aftermaxDate, even though no day was clicked and August days are visually disabled.
Expected behavior
onChange should likely not fire when navigating months in a date that violates maxDate or minDate. The calendar should navigate to show the new month view but the selected value should remain unchanged until the user explicitly clicks a valid day.
Activity
JasonStoltz commentedon May 19, 2026
We prioritized this at the top of our Do Next backlog assuming that it is a quick fix.