-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EuiDatePicker] onSelect is fired when navigating between months #4270
Comments
Thanks as always for the repro link, @smhutch I think a single |
Thanks @thompsongl, repo links feel especially important when I'm using some complex combinations of props. I usually make them to confirm if it's an issue in
I'm not sure if that makes sense, at least it would be problematic for the way I'm trying to use the component currently. In my case, I have an <EuiDatePicker
// only show certain dates (derived from some other application state)
includeDates={
data
? Object.keys(data).map((isoDate) => moment(isoDate).tz(timezone))
: []
}
onSelect={(momentDate, event) => {
// Hack alert. onSelect is fired when changing month.
// event is only defined when actually selecting a date.
if (event && momentDate && data) {
const isoDate = momentDate.format(API_DATE_FORMAT);
dispatch({
type: 'setDate',
availability: data[isoDate],
date: isoDate,
});
onProceed();
}
}}
inline
/> I guess what I'm looking for is an event which fires when a date is explicitly clicked on (which triggers the picker to close, in this new repo) |
Does setting |
@thompsong Thanks! I can confirm that setting I'll keep this ticket open, but edit the description to reflect this. |
This will be resolved once #4243 merges |
Resolved by #4243 |
About
onSelect
is fired twice when navigating between months InEuiDatePicker
. My feeling is that it should not fire at all, until the user selects a date. Or, if changing month is considered selection, it should only fire once.The same behaviour exists for
onChange
(though I changed to usingonSelect
, since it seems reasonable foronChange
to be called when changing month).Steps to replicate
Sandbox showing the issue. To see the issue, open the console, and check for calls to
onSelect
when:Note
Setting
adjustDateOnChange={false}
prevents this behavior.The text was updated successfully, but these errors were encountered: