diff --git a/addon/globalPlugins/webAccess/gui/rule/criteriaEditor.py b/addon/globalPlugins/webAccess/gui/rule/criteriaEditor.py index 9a9414bb..d87ae988 100644 --- a/addon/globalPlugins/webAccess/gui/rule/criteriaEditor.py +++ b/addon/globalPlugins/webAccess/gui/rule/criteriaEditor.py @@ -471,7 +471,8 @@ def initData(self, context): else: for index in range(nbAlternatives): self.sequenceOrderChoice.Append(str(index + 1)) - index = data.get("criteriaIndex", nbAlternatives + 1) + # Default to the last position (append) if unset, e.g. when adding a new alternative. + index = data.get("criteriaIndex", nbAlternatives - 1) self.sequenceOrderChoice.SetSelection(index) if self.getRuleType() == ruleTypes.ZONE: key = "convert.single" if isDualNode(data) else "convert.dual" diff --git a/addon/globalPlugins/webAccess/gui/rule/editor.py b/addon/globalPlugins/webAccess/gui/rule/editor.py index 2fa00ac5..8ccf62cd 100644 --- a/addon/globalPlugins/webAccess/gui/rule/editor.py +++ b/addon/globalPlugins/webAccess/gui/rule/editor.py @@ -1092,7 +1092,12 @@ def onCriteriaChange(self, change: Change, index: int): parent = self.Parent dlg = parent.Parent.Parent if change is Change.CREATION: - dlg.switchToFullEditor() + # The new alternative has already been inserted into the rule's criteria + # list. Do not flush the currently shown single-node panel: it still holds + # the widget values of the previous sole alternative and, since indices may + # have shifted, could otherwise overwrite the newly created alternative's + # data with stale data (e.g. when it is reordered to the first position). + dlg.switchToFullEditor(updateData=False) return parent.switchToAppropriatePanel() parent.shownPanel.initData(self.context) @@ -1417,11 +1422,12 @@ def onCharHook(self, evt): return super().onCharHook(evt) - def switchToFullEditor(self): + def switchToFullEditor(self, updateData=True): if not self.simpleMode: wx.Bell() return - self.currentCategory.updateData() + if updateData: + self.currentCategory.updateData() tree = self.catListCtrl treePath = [] child = tree.GetSelection()