@samitouri / QOS-React / commits / 64287af8d1

Set date to initial value when reset (#10412)

Brandon Dail committed Aug 9, 2017 at 10:52 UTC 64287af8d1f9f89f4493644ddc9c205dddf36c44
1 file changed +5 -5
fixtures/dom/src/components/fixtures/date-inputs/switch-date-test-case.js
+5 -5
@@ -1,5 +1,6 @@
1 const React = window.React;
2
3 +const startDate = new Date();
4 /**
5 * This test case was originally provided by @richsoni,
6 * https://github.com/facebook/react/issues/8116
@@ -7,7 +8,7 @@ const React = window.React;
8 class SwitchDateTestCase extends React.Component {
9 state = {
10 fullDate: false,
10 - date: new Date(),
11 + date: startDate,
12 };
13
14 render() {
@@ -50,10 +51,9 @@ class SwitchDateTestCase extends React.Component {
51 }
52 }
53
53 - onInputChange = event => {
54 - this.setState({
55 - date: new Date(Date.parse(event.target.value)),
56 - });
54 + onInputChange = ({target: {value}}) => {
55 + const date = value ? new Date(Date.parse(value)) : startDate;
56 + this.setState({date});
57 };
58
59 updateFullDate = () => {