Skip to content
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

fix/2584: refactored sort function #2630

Merged
merged 1 commit into from Mar 29, 2024

Conversation

JakubEleniuk
Copy link
Contributor

Description

Fixes #2584

From my manual testing everything looks fine.

Checklist

  • Created tests which fail without the change (if possible)
  • All tests passing (yarn test)
  • Extended the README / documentation, if necessary

else
return nodes.sort((b, a) => ((b.x ?? 1000) + (b.y ?? 1000) * column)-((a.x ?? 1000) + (a.y ?? 1000) * column));
return nodes.sort((a, b) => {
let diffY = dir * (a.y - b.y);
Copy link
Member

@adumesny adumesny Mar 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is incorrect because x and y could be undefined (auto position) which is why I default to 1000 to be last, but still sorted relative to other items.
But looking at your code I realize I don't really need column at all since it's just relative and Y trumps anything else...

@adumesny adumesny merged commit ea44523 into gridstack:master Mar 29, 2024
adumesny added a commit to adumesny/gridstack.js that referenced this pull request Mar 29, 2024
* fix gridstack#2630 to handle undefined x,y values again

POSSIBLE BREAKING CHANGE
* Utils.sort() and GridStackEngine.sortNodes() no longer take column as not needed actually...
@adumesny adumesny mentioned this pull request Mar 29, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] The order of the grids can break, when the page is loading on small screen, with Responsive Layouts
2 participants