-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Update MomentJS dependency #9382
Merged
jansiegel
merged 10 commits into
develop
from
feature/snyk-fix-c3454c61088848cba1ba001bfb76870c
Apr 22, 2022
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
dacbb1c
Update MomentJS dependency
budnix 5ec0fa6
Updating momentJS fixes an issue with sorting date values
budnix ea70b74
Fix dateFormat pattern
budnix 14478db
Merge branch 'develop' into feature/snyk-fix-c3454c61088848cba1ba001b…
jansiegel b93245b
- Correct the date format on the remaining cases in multiColumnSortin…
jansiegel 396c584
Bump moment dependency for the 'handsontable' workspace and the root …
jansiegel e2eb31c
Merge branch 'develop' into feature/snyk-fix-c3454c61088848cba1ba001b…
jansiegel a3785fb
Merge branch 'develop' into feature/snyk-fix-c3454c61088848cba1ba001b…
jansiegel 07459a3
Docs: Adding docs changes related to the Moment.js dependency update …
6d7012d
Merge branch 'develop' into feature/snyk-fix-c3454c61088848cba1ba001b…
jansiegel File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"title": "Update MomentJS dependency to 2.29.2.", | ||
"type": "fixed", | ||
"issue": 9381, | ||
"breaking": false, | ||
"framework": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 need some root-cause analysis of why is this changed.
Maybe the reviewer (@jansiegel) can explain this? I know that @budnix is busy with other issues.
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.
It seems that before updating the lib, the date values sorting does not work correctly. At least in that test case. For example, the results for sorting rows ascending:
Before (it's sorted without any noticeable pattern):
After:
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 am sorry, but this is not the root cause. The root cause seems related to the fact that the test, despite its name, provided wrongly formatted data to Moment.js, and tested that Moment.js does not sort in that case. After the change, Moment.js sorts even when it is given wrongly formatted data.
Compare the format given in line 1009 and the data provided in lines 996-1002
handsontable/handsontable/src/plugins/columnSorting/__tests__/columnSorting.spec.js
Lines 993 to 1009 in 5ec0fa6
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 think it was sorted kind of as a string, so in this case by the month number
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.
Maybe we should use Moment.js in the strict mode? https://momentjs.com/guides/#/parsing/strict-mode/
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 would be for it. It's better to only sort the date-type values based on the
dateFormat
. Without leaving the room for guesses.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.
A partial root cause analysis by me:
Date
constructormoment('01/14/2006', 'mm/dd/yy')
was not parsed at all. TheDate
constructor fallback returned the current datetime (https://jsfiddle.net/warpech/d9qako0g/4/)yy
became significant and that date was parsed without resolving to theDate
constructor. However, parsing is not good either. Moment parses this date to2006-01-01
. (https://jsfiddle.net/warpech/d9qako0g/4/)strict
flag turned off, all tested Moment versions from 2.24.0 to 2.29.2 consistently say it is an incorrect date.TL;DR Moment team unknowingly changed the interpretation of incorrect dates. If we used
strict
, the problem would not appear. Because we didn't use strict, the problem slipped through.I think we should enforcestrict
with an explanation in the migration guide.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 was advised that there are parts of Handsontable that treat the forgiving mode as a feature and we should not remove it. Discussion: https://handsoncode.slack.com/archives/C4PV4S33Q/p1650384660407479?thread_ts=1649328227.856499&cid=C4PV4S33Q