From aed96fd625c23d720f0f4a684c1fcd62b7399be7 Mon Sep 17 00:00:00 2001 From: MG12 Date: Wed, 16 Dec 2015 16:45:08 +0800 Subject: [PATCH] fixed bugs when value empty. --- HISTORY.md | 5 +++++ package.json | 2 +- src/module/Combobox.jsx | 6 ++++-- src/module/Panel.jsx | 4 ++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 48c386a..f72f67a 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,11 @@ --- +1.0.0-alpha9 / 2015-12-16 +------------------ + +`fixed` update bugs when value empty. + 1.0.0-alpha7 / 2015-12-12 ------------------ diff --git a/package.json b/package.json index a8ca6ad..61aabc7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-time-picker", - "version": "1.0.0-alpha8", + "version": "1.0.0-alpha9", "description": "React TimePicker", "keywords": [ "react", diff --git a/src/module/Combobox.jsx b/src/module/Combobox.jsx index 7374b39..f1e7c5b 100644 --- a/src/module/Combobox.jsx +++ b/src/module/Combobox.jsx @@ -79,7 +79,8 @@ const Combobox = React.createClass({ }, getMinuteSelect(minute) { - const { prefixCls, minuteOptions, disabledMinutes, value } = this.props; + const { prefixCls, minuteOptions, disabledMinutes } = this.props; + const value = this.props.value || this.getNow(); const disabledOptions = disabledMinutes(value.getHourOfDay()); return ( @@ -95,10 +96,11 @@ const Combobox = React.createClass({ }, getSecondSelect(second) { - const { prefixCls, secondOptions, disabledSeconds, showSecond, value } = this.props; + const { prefixCls, secondOptions, disabledSeconds, showSecond } = this.props; if (!showSecond) { return null; } + const value = this.props.value || this.getNow(); const disabledOptions = disabledSeconds(value.getHourOfDay(), value.getMinutes()); return ( diff --git a/src/module/Panel.jsx b/src/module/Panel.jsx index 94d3842..4c3d071 100644 --- a/src/module/Panel.jsx +++ b/src/module/Panel.jsx @@ -78,8 +78,8 @@ const Panel = React.createClass({ const { locale, prefixCls, placeholder, disabledHours, disabledMinutes, disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showSecond, formatter, gregorianCalendarLocale } = this.props; const value = this.state.value; const disabledHourOptions = disabledHours(); - const disabledMinuteOptions = disabledMinutes(value.getHourOfDay()); - const disabledSecondOptions = disabledSeconds(value.getHourOfDay(), value.getMinutes()); + const disabledMinuteOptions = disabledMinutes(value ? value.getHourOfDay() : null); + const disabledSecondOptions = disabledSeconds(value ? value.getHourOfDay() : null, value ? value.getMinutes() : null); const hourOptions = generateOptions(24, disabledHourOptions, hideDisabledOptions); const minuteOptions = generateOptions(60, disabledMinuteOptions, hideDisabledOptions); const secondOptions = generateOptions(60, disabledSecondOptions, hideDisabledOptions); -- 2.41.0