piffy
2024 年8 月 9 日 06:37
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 个赞
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
2024 年8 月 9 日 06:44
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 个赞
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
2024 年8 月 9 日 07:03
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 个赞
Thanks for the report. I’ll take a look.
3 个赞
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 个赞
This has been merged, please confirm all is now resolved.
1 个赞
This topic was automatically closed after 3 days. New replies are no longer allowed.