-
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
Changes from 7 commits
dacbb1c
5ec0fa6
ea70b74
14478db
b93245b
396c584
e2eb31c
a3785fb
07459a3
6d7012d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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" | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1051,7 +1051,7 @@ describe('ColumnSorting', () => { | |||||||||||||||||||||||||||||||||||
{}, | ||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||
type: 'date', | ||||||||||||||||||||||||||||||||||||
dateFormat: 'mm/dd/yy' | ||||||||||||||||||||||||||||||||||||
dateFormat: 'MM/DD/YYYY' | ||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||
type: 'numeric' | ||||||||||||||||||||||||||||||||||||
|
@@ -1063,19 +1063,19 @@ describe('ColumnSorting', () => { | |||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
getPlugin('columnSorting').sort({ column: 2, sortOrder: 'asc' }); // ASC | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(0)).toEqual(['Mercedes', 'A 160', '01/14/2006', 6999.9999]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(1)).toEqual(['Opel', 'Astra', '02/02/2004', 7000]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(2)).toEqual(['BMW', '320i Coupe', '07/24/2011', 30500]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(3)).toEqual(['Audi', 'A4 Avant', '11/19/2011', 33900]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(4)).toEqual(['Citroen', 'C4 Coupe', '12/01/2008', 8330]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(0)).toEqual(['Opel', 'Astra', '02/02/2004', 7000]); | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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): '01/14/2006'
'02/02/2004'
'07/24/2011'
'11/19/2011'
'12/01/2008' After: '02/02/2004'
'01/14/2006'
'12/01/2008'
'07/24/2011'
'11/19/2011' There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A partial root cause analysis by me:
TL;DR Moment team unknowingly changed the interpretation of incorrect dates. If we used
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(1)).toEqual(['Mercedes', 'A 160', '01/14/2006', 6999.9999]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(2)).toEqual(['Citroen', 'C4 Coupe', '12/01/2008', 8330]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(3)).toEqual(['BMW', '320i Coupe', '07/24/2011', 30500]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(4)).toEqual(['Audi', 'A4 Avant', '11/19/2011', 33900]); | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
getPlugin('columnSorting').sort({ column: 2, sortOrder: 'desc' }); // DESC | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(0)).toEqual(['Citroen', 'C4 Coupe', '12/01/2008', 8330]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(1)).toEqual(['Audi', 'A4 Avant', '11/19/2011', 33900]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(2)).toEqual(['BMW', '320i Coupe', '07/24/2011', 30500]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(3)).toEqual(['Opel', 'Astra', '02/02/2004', 7000]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(4)).toEqual(['Mercedes', 'A 160', '01/14/2006', 6999.9999]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(0)).toEqual(['Audi', 'A4 Avant', '11/19/2011', 33900]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(1)).toEqual(['BMW', '320i Coupe', '07/24/2011', 30500]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(2)).toEqual(['Citroen', 'C4 Coupe', '12/01/2008', 8330]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(3)).toEqual(['Mercedes', 'A 160', '01/14/2006', 6999.9999]); | ||||||||||||||||||||||||||||||||||||
expect(getDataAtRow(4)).toEqual(['Opel', 'Astra', '02/02/2004', 7000]); | ||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
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.
This file also uses the old notation
dateFormat: 'mm/dd/yy'
on lines 294, 1532 (and also in 2 places inmultiColumnSorting.spec.js
).Why were other lines not affected?
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.
Those remaining tests seem to not be sorted by the column containing the dates, so the
dateFormat
is pretty much redundant, I'll change it, though.