Skip to content
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

Cannot select time with DatePicker when new props are passed #5189

Closed
megawac opened this issue Mar 6, 2017 · 2 comments
Closed

Cannot select time with DatePicker when new props are passed #5189

megawac opened this issue Mar 6, 2017 · 2 comments
Labels
🐛 Bug Ant Design Team had proved that this is a bug.

Comments

@megawac
Copy link
Contributor

megawac commented Mar 6, 2017

When a Form rendering a DatePicker with showTime prop gets updated because its parent component sent new props (in this case a prop not even relevant to the contents of the form), the DatePicker won't let you select a value (unless by clicking a preset button).

Minimal reproduction case:

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import { DatePicker, Layout, Form } from 'antd';

class BagSnapshot extends React.Component {
  submit(e) {
    e.preventDefault();
    this.props.form.validateFields((err, fieldsValue) => {
      // ...
    });
  }

  render() {
    const {getFieldDecorator} = this.props.form;
    const endTimeConfig = {};

    return (
      <Form
        onSubmit={this.submit.bind(this)}
      >
        <Form.Item>
          {getFieldDecorator('endTime', endTimeConfig)(
            <DatePicker
              showTime={{
                format: 'HH:mm'
              }}
              format="lll"
              style={{
                width: '100%'
              }}
            />
          )}
        </Form.Item>
      </Form>
    );
  }
}

let MyForm = Form.create({
  hideRequiredMark: true
})(BagSnapshot);

class App extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      test: {
        a: 1
      }
    }

    setInterval(() => {
      this.setState({
        test: {
          a: 123
        }
      })
    }, 100);
  }

  render() {
    console.log('render');
    return (
      <MyForm
        test={this.state.test}
      />
    );
  }
}

ReactDOM.render(<App />, document.getElementById('root'));
@ddcat1115 ddcat1115 added the 🐛 Bug Ant Design Team had proved that this is a bug. label Mar 6, 2017
@megawac
Copy link
Contributor Author

megawac commented Mar 6, 2017

FYI, this doesn't appear to be an issue with the RangePicker.

@lock
Copy link

lock bot commented May 2, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐛 Bug Ant Design Team had proved that this is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants