Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

date knob calendar fails to select different date #84

Closed
danielkcz opened this issue Jan 24, 2017 · 4 comments
Closed

date knob calendar fails to select different date #84

danielkcz opened this issue Jan 24, 2017 · 4 comments

Comments

@danielkcz
Copy link

danielkcz commented Jan 24, 2017

It's very strange. I can click on any date in the calendar, it gets highlighted shortly, even date in the input updates, but then it gets reverted back to today date. Not even time can be changed.

"@kadira/storybook": "^2.35.2",
"@kadira/storybook-addon-knobs": "^1.7.1",
"react": "^15.4.1",
"react-dom": "^15.4.1",
@gthomas-appfolio
Copy link

gthomas-appfolio commented Mar 17, 2017

I think the issue is the same as #68 , the date knob passes a timestamp (a number), not a Date object
like you'd expect

@tko
Copy link

tko commented Mar 20, 2017

Other than being broken internally I don't think the return type matters here, e.g.

<span>{date('date')}</span>

shows how date reverts back to its original value.

@tko
Copy link

tko commented Mar 20, 2017

Interestingly, if I pass in a default value that is a global variable the date picker seems to work. But creating it on the fly, i.e. date('date', new Date()) is similarly broken as not passing it at all.

@tko
Copy link

tko commented Mar 21, 2017

On further thought given the implementation details of KnobManager the calling convention date('x', new Date()) is never going to work as intended since the defaultValue is always going to be different. Basically anything that is derived from current time at the time of the call to 'date' can not work without additional support.

To support a default value of "now" (with or without some relative +/- time) I think date needs to add support for a different calling convention where the defaultValue declaration is static that can be compared for equality, e.g. caller provides {now: true} or {days: +7} or {days: -7} which is translated into an internal defaultValue representation, say using JSON.stringify, which checks out for equality and gets past KnobManager.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants