components icon indicating copy to clipboard operation
components copied to clipboard

fix(material/table): sorting column breaks if contains a number with zero left

Open viniciusschuelter opened this issue 2 years ago • 4 comments

Fix https://github.com/angular/components/issues/20140 that when sorting column breaks if one or more record contains a number with zero left. This is specifically happen when the value is a number with zero left(ex: '0123'), so the funcion "_isNumberValue" understand this like a number and then the value is convert to 123. The approach i used was to return the default value only in this specific case.

viniciusschuelter avatar Aug 11 '22 01:08 viniciusschuelter

The original issue doesn't appear to be a problem in v14: https://stackblitz.com/edit/angular-elb4wq?file=src%2Fapp%2Ftable-sorting-example.ts

I believe the remaining issue here is that the function doesn't do well to sort an array with both numbers and arrays. Can you confirm this is an issue if the array has a consistent type, e.g. all strings?

andrewseguin avatar Aug 18 '22 19:08 andrewseguin

Hey andrew @andrewseguin, this is a bit most specific, check with this data https://stackblitz.com/edit/angular-elb4wq-bbrdge?file=src%2Fapp%2Ftable-sorting-example.ts, i think the "06' should be on the first place, this is happening because '06' is a number with zero left

viniciusschuelter avatar Aug 19 '22 14:08 viniciusschuelter

yeah it does seem like something is off, but I'm trying to determine what the best solution is - I tried testing this internally and there was a failure, and I'll need to see why that is. Thanks for your patience, trying to make sure this stays prioritized

andrewseguin avatar Aug 31 '22 12:08 andrewseguin

No problems Andrew, i remain available if needed.

viniciusschuelter avatar Aug 31 '22 13:08 viniciusschuelter