-
Notifications
You must be signed in to change notification settings - Fork 867
Add onSubtractTime and onAddTime hooks #508
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
Conversation
Hi @DaanDD and thanks for contributing! Your code is changing a critical part of the component but you didn't write any tests. I would like to see some tests that verifies that it's working as you want it to work. Also, no need to update the dist files. We do that when we release a new version, please remove them from your PR. Thanks! |
Hello, thanks for the feedback! I have removed the dist files and added some tests. |
DateTime.d.ts
Outdated
Callback trigger when the user navigates to the next month, year or group of years. | ||
The callback receives the amount and type ('month', 'year') as parameters. | ||
*/ | ||
onAddTime?: (amount: number, type: string) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These name has time
in them, but they are triggered for "months, year or group of years". It might be confusing for the user since the component has a time mode.
Naming is hard for these triggers, onSubtractMonthsOrYears
is more correct but it's long.
What are your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onSubtractMonthsOrYears
seems a bit long, maybe something like onNavigateBack
and onNavigateForward
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that better, because navigating time doesn't really make sense. Let's go with that, what do you say?
test/tests.spec.js
Outdated
@@ -1062,6 +1062,64 @@ describe('Datetime', () => { | |||
|
|||
}); | |||
|
|||
describe('onSubtractTime', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are testing onAddTime
here and onSubtractTime
in the next describe()
, a mixup :)
…Back and onNavigateForward
@simeg I have changed the hook names. |
Looks good 👍 Thanks for contributing! |
I am trying to call "onNavigateBack" and "onNavigateForward" both are not working. "onViewModeChange" is working well.
|
It worked for me If I install this package like |
Description
Implement hooks for onSubtractTime and onAddTime.
Motivation and Context
This could be used to dynamically load selectable dates for each month.
Checklist
I have ran build but it seems to have updated more than only my changes in the dist folder.