Fix alternative criteria reordering when adding second alternative - #63
Merged
Conversation
AAClause
marked this pull request as ready for review
September 2, 2026 17:10
AAClause
force-pushed
the
bugfix/second_alternative
branch
3 times, most recently
from
September 2, 2026 17:35
8c686b0 to
b79cecd
Compare
When a rule has exactly one alternative, the Rule Editor uses "Simple Mode" and edits it through SimpleSingleNodeCriteriaPanel, whose getData() always targets criteria[0]. Clicking "Add alternatives" correctly inserts the new alternative into the rule's criteria list, then calls RuleEditorDialog.switchToFullEditor() to reload the dialog in full mode. That method unconditionally flushes the currently shown (now stale) single-node panel via updateData(), which writes its widget values -- still reflecting the previous sole alternative -- into criteria[0]. If the new alternative was reordered to the first position, this silently overwrites its freshly entered data with the old alternative's data. Left at the default last position, criteria[0] is still the old alternative, so the overwrite is a no-op, which is why the bug only surfaced when reordering a newly added second alternative to position 1. Fix switchToFullEditor() to accept an opt-out for this flush, and use it from the alternative-creation path where the data has already been persisted through the Criteria Set editor and must not be re-flushed from the stale panel. Also fix the Criteria Set editor's sequence order default, which used an out-of-range fallback constant (nbAlternatives + 1) instead of the last valid position (nbAlternatives - 1). Fixes #62
AAClause
force-pushed
the
bugfix/second_alternative
branch
from
September 2, 2026 18:11
b79cecd to
90009de
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes issue where entering data for a new alternative and changing its
order would cause the data to be lost, duplicating the existing alternative's
data instead.
Fixes #62