-
-
Notifications
You must be signed in to change notification settings - Fork 735
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
Expose onBlur prop #122
Comments
👍 Makes sense, thanks for the idea. I would even adopt the spread operator, but take care! It requires to remove some HTML attributes, such as handleKeyDown(e) {
e.persist();
const { canChangeMonth, onKeyDown } = this.props;
if (!canChangeMonth && onKeyDown) {
onKeyDown(e);
return;
}
if (canChangeMonth) {
const callback = onKeyDown ? () => onKeyDown(e) : null;
switch (e.keyCode) {
case keys.LEFT:
this.showPreviousMonth(callback);
break;
case keys.RIGHT:
this.showNextMonth(callback);
break;
}
}
},
// snip
render() {
const { numberOfMonths, locale, canChangeMonth, onDayClick, onDayTouchTap, ...attributes } = this.props;
const { currentMonth } = this.state;
let className = `DayPicker DayPicker--${locale}`;
if (!onDayClick && !onDayTouchTap) {
className = `${className} DayPicker--interactionDisabled`;
}
if (attributes.className) {
className = `${className} ${attributes.className}`;
}
const months = [];
let month;
for (let i = 0; i < numberOfMonths; i++) {
month = DateUtils.addMonths(currentMonth, i);
months.push(this.renderMonth(month, i));
}
return (
<div role="widget" onKeyDown={ ::this.handleKeyDown } {...attributes}>
{ canChangeMonth && this.renderNavBar() }
{ months }
</div>
);
} Please use |
awesome! alright, I'll work on it after I sleep! I might cast some ancient magic spell I'm not aware of. |
lol @srph then have a good sleep with magic dreams 🍄 |
This would allow us to pass event listeners and all sort of things. See gpbl#122.
<DayPicker onBlur={} />
I have a use-case for there where the DayPicker appears as a popover.
ATM, I show/hide the datepicker through a state (active when the input is focused; inactive on blur). However, clicking the DayPicker div changes the focus from the input to the
DayPicker
.I have no means of checking if the user has focused away from the
DayPicker
.<DayPicker onDayClick={...} {...other} />
).I'm willing to send a PR, just need some approval first.
The text was updated successfully, but these errors were encountered: