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

Regression in DateInput #340

Closed
ggregoire opened this issue Dec 9, 2016 · 7 comments
Closed

Regression in DateInput #340

ggregoire opened this issue Dec 9, 2016 · 7 comments

Comments

@ggregoire
Copy link

ggregoire commented Dec 9, 2016

Hi guys!

I got a regression in updating from 1.1.0 to 1.2.0 (latest).

The bug comes from this PR.

The component crashes during its instantiation because of this change.

Some screenshots:

screen shot 2016-12-09 at 00 47 57

screen shot 2016-12-09 at 00 47 24

It worked before to pass a string to the component because of the moment(date).

Now it doesn't work anymore because of the moment([date.getFullYear(), ...]).

To be honest, your doc says that value should be a Date and not a string, so...

We could indicate in the changelog the potential breaking change and a possible solution, e.g.

replacing value={value} by value={new Date(value)}

Or maybe a workaround in the code to keep the previous behaviour?

@cmslewis
Copy link
Contributor

cmslewis commented Dec 9, 2016

Thanks for filing, @ggregoire! This is helpful context, but I'm going to close this as a duplicate so that we can track the issue in a single place in #280. Feel free to chime in over there.

@adidahiya
Copy link
Contributor

Actually the correct duplicate is #322. Fixed for today's upcoming release.

@ggregoire
Copy link
Author

ggregoire commented Dec 9, 2016

Thanks for filing, @ggregoire! This is helpful context, but I'm going to close this

Fixed for today's upcoming release.

Guys, did you read my bug description beyond the first 3 lines?

How this fix could fix this?

screen shot 2016-12-09 at 00 47 24

Could you change this

if (null == date) {
    return moment(null);
}

to

if (null == date || typeof date === "string") {
    return moment(date);
}

for today's upcoming release?

Thanks.

@ggregoire
Copy link
Author

Some tests to avoid future regressions:

it("renders without crashing", () => {
  const DATE_NULL = null;
  ReactDOM.render(<DateInput value={DATE_NULL} />, document.createElement("div"))

  const DATE_STRING = "1988-08-07 11:01:12";
  ReactDOM.render(<DateInput value={DATE_STRING} />, document.createElement("div"))
})

@adidahiya
Copy link
Contributor

Hey, you're right @ggregoire, sorry I overlooked that. Opened a new PR #342 which we will try to merge for today's upcoming release.

@adidahiya adidahiya added this to the 1.3.0 milestone Dec 9, 2016
@ggregoire
Copy link
Author

ggregoire commented Dec 9, 2016

@adidahiya @cmslewis @giladgray Thanks for looking into it! :)

@cmslewis
Copy link
Contributor

cmslewis commented Dec 9, 2016

Whoops, sorry about that @ggregoire. Thanks for staying vigilant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants