Skip to content

fix/2584: refactored sort function#2630

Merged
adumesny merged 1 commit into
gridstack:masterfrom
JakubEleniuk:fix/2584-wrong-widget-order
Mar 29, 2024
Merged

fix/2584: refactored sort function#2630
adumesny merged 1 commit into
gridstack:masterfrom
JakubEleniuk:fix/2584-wrong-widget-order

Conversation

@JakubEleniuk

Copy link
Copy Markdown
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

Comment thread src/utils.ts
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);

@adumesny adumesny Mar 29, 2024

Copy link
Copy Markdown
Member

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