Skip to content

Commit

Permalink
Merge pull request #16030 from craftcms/bugfix/16026-embedded-index-a…
Browse files Browse the repository at this point in the history
…nd-reordering

fixes issue with nested elements reordering when count >= 50
  • Loading branch information
brandonkelly authored Nov 7, 2024
2 parents 04fd226 + 89cff84 commit e46e1ea
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Fixed a bug where structure data wasn’t getting deleted for drafts when moving an entry out of a Structure section. ([#15949](https://github.com/craftcms/cms/issues/15949), [#16014](https://github.com/craftcms/cms/pull/16014))
- Fixed a bug where loading spinners weren’t always centered. ([#16013](https://github.com/craftcms/cms/pull/16013))
- Fixed a race condition that could break default entry creation for Matrix fields. ([#15999](https://github.com/craftcms/cms/pull/15999))
- Fixed a JavaScript error that occurred when sorting nested elements in an embedded element index, if the index was paginated. ([#16026](https://github.com/craftcms/cms/issues/16026))
- Updated Axios to 1.7.7. ([#15958](https://github.com/craftcms/cms/issues/15958))

## 5.4.9 - 2024-10-22
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions src/web/assets/cp/src/js/BaseElementIndexView.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ Craft.BaseElementIndexView = Garnish.Base.extend(
// Give sub-classes a chance to do post-initialization stuff here
this.afterInit();

// Set up lazy-loading
// Set up $scroller for reordering
if (
!this.elementIndex.paginated &&
(!this.elementIndex.paginated ||
this.elementIndex.settings.context === 'embedded-index') &&
this.elementIndex.settings.batchSize
) {
if (this.settings.context === 'index') {
Expand All @@ -135,8 +136,12 @@ Craft.BaseElementIndexView = Garnish.Base.extend(
}

this.$scroller.scrollTop(0);
this.addListener(this.$scroller, 'scroll', 'maybeLoadMore');
this.maybeLoadMore();

// and if we're not in a paginated view, set up lazy-loading
if (!this.elementIndex.paginated) {
this.addListener(this.$scroller, 'scroll', 'maybeLoadMore');
this.maybeLoadMore();
}
}
},

Expand Down
5 changes: 4 additions & 1 deletion src/web/assets/cp/src/js/ElementTableSorter.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ Craft.ElementTableSorter = Garnish.DragSort.extend(
this._setTargetLevelBounds();

// Check to see if we should load more elements now
this.tableView.maybeLoadMore();

if (!this.tableView.elementIndex.paginated) {
this.tableView.maybeLoadMore();
}

this.base();
},
Expand Down

0 comments on commit e46e1ea

Please sign in to comment.