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

[TimePicker] allow set time to null #2108

Merged
merged 1 commit into from
Nov 13, 2015
Merged

Conversation

qnub
Copy link
Contributor

@qnub qnub commented Nov 9, 2015

When i try to set time picker back to null it raises error getHours undefined in null so now i need to make custom hack:

  resetTime(){
    const emptyTime = new Date();
    emptyTime.setHours(0);
    emptyTime.setMinutes(0);
    emptyTime.setSeconds(0);
    emptyTime.setMilliseconds(0);

    this.refs.time.setState({
      time: emptyTime
    });
    this.refs.time.refs.input.setValue(null);
  }

When try to set time picker back to `null` it raise error `getHours undefined in null` so now i need to make custom hack:

```
  resetTime(){
    const emptyTime = new Date();
    emptyTime.setHours(0);
    emptyTime.setMinutes(0);
    emptyTime.setSeconds(0);
    emptyTime.setMilliseconds(0);

    this.refs.time.setState({
      time: emptyTime
    });
    this.refs.time.refs.input.setValue(null);
  }
```
@oliviertassinari
Copy link
Member

I think that in the future, we should remove setTime from the API. I would rather add a controlled property: time (very similar to the uncontrolled one defaultTime) than pursuing changing this API.
@qnub @shaurya947 What do you think?

@shaurya947
Copy link
Contributor

props over methods any day, @oliviertassinari 👍

@qnub
Copy link
Contributor Author

qnub commented Nov 10, 2015

@oliviertassinari Yeah, it'll be good. Alongside with respect of switches to null/undefined values in this prop 👍

@shaurya947
Copy link
Contributor

@oliviertassinari OK to merge?

@oliviertassinari
Copy link
Member

👍

oliviertassinari added a commit that referenced this pull request Nov 13, 2015
[TimePicker] allow set time to null
@oliviertassinari oliviertassinari merged commit 2516174 into mui:master Nov 13, 2015
@oliviertassinari
Copy link
Member

@qnub Thanks!

@qnub qnub deleted the patch-1 branch November 14, 2015 16:49
@zannager zannager added component: time picker This is the name of the generic UI component, not the React module! component: pickers This is the name of the generic UI component, not the React module! labels Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! component: time picker This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants