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

date knob calendar fails to select different date #804

Closed
shilman opened this issue Apr 15, 2017 · 4 comments
Closed

date knob calendar fails to select different date #804

shilman opened this issue Apr 15, 2017 · 4 comments

Comments

@shilman
Copy link
Member

shilman commented Apr 15, 2017

Issue by FredyC
Tuesday Jan 24, 2017 at 19:58 GMT
Originally opened as storybook-eol/storybook-addon-knobs#84


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",
@shilman
Copy link
Member Author

shilman commented Apr 15, 2017

Comment by gthomas-appfolio
Friday Mar 17, 2017 at 23:16 GMT


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

@shilman
Copy link
Member Author

shilman commented Apr 15, 2017

Comment by tko
Monday Mar 20, 2017 at 19:20 GMT


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.

@shilman
Copy link
Member Author

shilman commented Apr 15, 2017

Comment by tko
Monday Mar 20, 2017 at 19:28 GMT


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.

@shilman
Copy link
Member Author

shilman commented Apr 15, 2017

Comment by tko
Tuesday Mar 21, 2017 at 21:13 GMT


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 join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants