piffy
August 9, 2024, 6:37am
1
I am getting a bug when trying to edit a topic post with a poll in it.
To replicate
Make a new topic with a poll in it, like the one below
[poll name=pollA type=regular results=on_close public=true chartType=bar]
* Option
[/poll]
Publish the topic and vote in the poll
Refresh the page
Edit the topic post.
I get this error in my console and the page hangs, no composer preview is generated, etc.
import Component from "@glimmer/component";
import { concat } from "@ember/helper";
import { htmlSafe } from "@ember/template";
import i18n from "discourse-common/helpers/i18n";
import evenRound from "discourse/plugins/poll/lib/even-round";
import PollVoters from "./poll-voters";
export default class PollResultsStandardComponent extends Component {
orderOptions = (options) => {
return options.sort((a, b) => {
if (a.votes < b.votes) {
return 1;
} else if (a.votes === b.votes) {
if (a.html < b.html) {
return -1;
} else {
return 1;
}
} else {
return -1;
This file has been truncated. show original
I think this NaN% could be related:
I hope I can replicate it on here, trying now.
Sadly, it seems I canāt replicate it on meta here. I did do a fresh update before testing on my instance, currently running 3.4.0.beta1-dev ( a3d61ba1c4 )
Not sure if it matters but I have poll edit window mins
set to 90 mins
3 Likes
Tested with version 3.4.0.beta1-dev and it works fine
Tested with poll edit windows mins
set to 90
[poll name=pollA type=regular results=on_close public=true chartType=bar]
* Option
[/poll]
Voted in poll and then edited topic
Have you tried in safe mode ?
http://discourse.example.com/safe-mode
piffy
August 9, 2024, 6:44am
3
I tried in safe mode with no themes (and replicated the issue) but unfortunately I canāt try with no plugins because the polling is a plugin
1 Like
Ah got it to happen on mineā¦
Recap
Version
3.4.0.beta1-dev
Setting
Tested with poll edit windows mins
set to 90
Poll
[poll name=pollA type=regular results=on_close public=true chartType=bar]
* Option
[/poll]
Error
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '0b05a21ff916fbd0f86b5172a2817610')
Possibly related to
name=pollA
@piffy Try this
[poll type=regular results=always public=true chartType=bar]
* Option
[/poll]
Edit: This seems to work fine so name=pollA
seems to be a problem
piffy
August 9, 2024, 7:03am
6
Thanks for the further investigation. It seems itās not the poll name that is the problem but actually the on_close
I forgot to add a close time to the poll in the OP (and now itās been >5 minutes so I canāt edit it anymore ). But on my instance:
This one causes a problem
[poll name=pollB type=regular results=on_close public=true chartType=bar close=2024-08-15T19:00:00.000Z]
* Option
[/poll]
This one seems to have no issue
[poll name=pollC type=regular results=always public=true chartType=bar]
* Option
[/poll]
2 Likes
Thanks for the report. Iāll take a look.
3 Likes
Tested this
[poll name=pollB type=regular results=on_close public=true chartType=bar close=2024-08-15T19:00:00.000Z]
* Option
[/poll]
Works fine for me, no errors
See Can't Edit Topic with Poll, Bug Occurs? - #4 by Vaping_Community
I believe Iāve identified the issue.
I believe correctly, when the poll is set to āresults ON_CLOSEā, vote numbers for each option are only streamed to the browser when the vote is Closed.
The issue is that when you refresh the page, the default view is results, which for this type of poll should NOT happen.
The Results view should not be possible to see until closure, even for the Author.
So the fix here is making sure the default view (for polls that have results on close) is the voting view until the Poll is Closed.
Iāll prepare a PR.
4 Likes
merefield
(Robert)
August 13, 2024, 10:41am
11
This has been merged, please confirm all is now resolved.
1 Like
This topic was automatically closed after 3 days. New replies are no longer allowed.