Skip to content

Fix observation and comment persistence when switching vote types - #76

Merged
IvoLeist merged 6 commits into
mainfrom
copilot/fix-state-persistence-bug
Feb 23, 2026
Merged

Fix observation and comment persistence when switching vote types#76
IvoLeist merged 6 commits into
mainfrom
copilot/fix-state-persistence-bug

Conversation

Copilot AI commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Vote submission was recording observations and comments regardless of whether the selected vote type supports them. When users switched from "None of the above" (which shows observation checkboxes) to "Yes" (which doesn't), stale observations remained in the database.

Changes

Vote submission logic (/R/mod_voting.R lines 371-388):

  • Only persist observations when agreement == "none_of_above", clear otherwise
  • Only persist comments when agreement ∈ {diff_var, none_of_above}, clear otherwise
# Before: saved if input contained any value
if (!is.null(input$observation)) {
  annotations_df[rowIdx, "observation"] <- paste(input$observation, collapse = ";")
}

# After: saved only when vote type supports it
if (new_agreement == "none_of_above" && !is.null(input$observation)) {
  annotations_df[rowIdx, "observation"] <- paste(input$observation, collapse = ";")
} else {
  annotations_df[rowIdx, "observation"] <- NA
}

Tests (tests/testthat/test-voting-module.R):

  • Vote type switch from none_of_aboveyes clears observations and comments
  • Vote type switch from diff_varyes clears comments
Original prompt

This section details on the original issue you should resolve

<issue_title>State persistence bug: “Other” sub-options and comment are still recorded after switching vote to e.g. “Yes”</issue_title>
<issue_description>
Bug (reprocuded by @MirandaStobbe on Thursday 19.02)

Observed behaviors:

Once you select one of the four sub options of "other",
it does not get unselected when you vote for something else.
It does stop showing them, but the one selected is still selected
Thus, there are record where even though yes was selected
there are still the sub options for "other" recorded

This also holds for the comment field.
If you write something there and then change your mind,
the comment is still recorded.

Expected:

  1. Once the user changes there mind and switching from "other"
    to e.g. "yes" all the selections should be cleared.

  2. The input in the comment field should not be cleared but
    not recorded for the selected options which do not come with
    comment field such as "yes"</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…type changes

Co-authored-by: IvoLeist <28399610+IvoLeist@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix state persistence issue for voting and comments Fix observation and comment persistence when switching vote types Feb 19, 2026
Copilot AI requested a review from IvoLeist February 19, 2026 10:22
@IvoLeist
IvoLeist marked this pull request as ready for review February 23, 2026 15:41
@IvoLeist
IvoLeist merged commit bc1e310 into main Feb 23, 2026
1 check passed
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.

State persistence bug: “Other” sub-options and comment are still recorded after switching vote to e.g. “Yes”

2 participants