From a71f6b7f1761bf6d836332d25129186f4a316760 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Tue, 5 Sep 2023 10:11:45 +0700 Subject: [PATCH] Update counter-last bugfix from PR #7712 The bugfix in this PR is now identical to the bugfix from PR #7712 so that we won't get merge conflicts no matter whether that PR or this one is merged first. --- core/modules/widgets/list.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/modules/widgets/list.js b/core/modules/widgets/list.js index 7d1b959fc69..0c242205f54 100755 --- a/core/modules/widgets/list.js +++ b/core/modules/widgets/list.js @@ -250,8 +250,8 @@ ListWidget.prototype.handleListChanges = function(changedTiddlers) { // If we are providing an counter variable then we must refresh the items, otherwise we can rearrange them var hasRefreshed = false,t; if(this.counterName) { - var mustRefreshOldLast = this.children.length < this.list.length; - var oldLastIdx = this.children.length-1; + var mustRefreshOldLast = false; + var oldLength = this.children.length; // Cycle through the list and remove and re-insert the first item that has changed, and all the remaining items for(t=0; t= 0) { + if(mustRefreshOldLast && oldLength > 0) { + var oldLastIdx = oldLength-1; this.removeListItem(oldLastIdx); this.insertListItem(oldLastIdx,this.list[oldLastIdx]); }