-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
numeric sort for component edits #1639
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
src/plot_api/manage_arrays.js
Outdated
@@ -101,7 +101,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, | |||
return true; | |||
} | |||
|
|||
var componentNums = Object.keys(edits).map(Number).sort(), | |||
var componentNums = Object.keys(edits).map(Number).sort(function(a, b) { return a - b; }), |
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 might want to use Lib.sorterAsc
to DRY it up 🌴
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.
ah thanks - should've guessed we'd have that already exposed somewhere!
@@ -223,6 +223,33 @@ describe('annotations relayout', function() { | |||
.then(done); | |||
}); | |||
|
|||
it('should sort correctly when index>10', function(done) { |
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.
nice test!
💃 after that little bit of 🌴 |
💃 |
Not the first time I've been bitten by the default sort being alphabetical even if the items are numbers... This made a bug where if you tried to add annotations 9 and 10 in a single
relayout
, it would try to add 10 first but it couldn't do that because 9 didn't exist yet (or if it did, 10 would get inserted in the array in the wrong places) and similar problems on deletion.@etpinard OK?