Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ const Calendar = createReactClass({
}) : null;
const dateInputElement = props.showDateInput ? (
<DateInput
ref="dateInput"
format={this.getFormat()}
key="date-input"
value={value}
Expand Down
2 changes: 1 addition & 1 deletion src/RangeCalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ const RangeCalendar = createReactClass({
nextMonthOfStart.month() === endValue.month();
return (
<div
ref="root"
ref={this.saveRoot}
className={classes}
style={props.style}
tabIndex="0"
Expand Down
10 changes: 8 additions & 2 deletions src/date/DateInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ const DateInput = createReactClass({
},

focus() {
this.refs.dateInput.focus();
if (this.dateInputInstance) {
this.dateInputInstance.focus();
}
},

saveDateInput(dateInput) {
this.dateInputInstance = dateInput;
},

render() {
Expand All @@ -107,7 +113,7 @@ const DateInput = createReactClass({
return (<div className={`${prefixCls}-input-wrap`}>
<div className={`${prefixCls}-date-input-wrap`}>
<input
ref="dateInput"
ref={this.saveDateInput}
className={`${prefixCls}-input ${invalidClass}`}
value={str}
disabled={props.disabled}
Expand Down
2 changes: 1 addition & 1 deletion src/mixin/CalendarMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const CalendarMixin = {

return (
<div
ref="root"
ref={this.saveRoot}
className={`${classnames(className)}`}
style={this.props.style}
tabIndex="0"
Expand Down
8 changes: 6 additions & 2 deletions src/mixin/CommonMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ export default {
},

focus() {
if (this.refs.root) {
this.refs.root.focus();
if (this.rootInstance) {
this.rootInstance.focus();
}
},

saveRoot(root) {
this.rootInstance = root;
},
};