# Can't Edit Topic with Poll, Bug Occurs?

**URL:** https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845
**Category:** Bug
**Tags:** polls, fixed
**Created:** [August 9, 2024, 6:37am UTC](https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845 "2024-08-09T06:37:53Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![piffy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/piffy/32/254198_2.png) [@piffy](https://meta.discourse.org/u/piffy)
#### Post date: [August 9, 2024, 6:37am UTC](https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845/1 "2024-08-09T06:37:53Z")

</div>

I am getting a bug when trying to edit a topic post with a poll in it.

To replicate

1. Make a new topic with a poll in it, like the one below

```plaintext
[poll name=pollA type=regular results=on_close public=true chartType=bar]
* Option
[/poll]

```

1. Publish the topic and vote in the poll

2. Refresh the page

3. Edit the topic post.

I get this error in my console and the page hangs, no composer preview is generated, etc.

 ![image](https://global.discourse-cdn.com/meta/original/4X/b/d/0/bd063c866166db3803add089d44bb16978f0f463.png)

> <https://github.com/discourse/discourse/blob/6d1862409e5b53ad070333bba8b859e493170bb8/plugins/poll/assets/javascripts/discourse/components/poll-results-standard.gjs>

I think this NaN% could be related:

 ![image](https://global.discourse-cdn.com/meta/original/4X/b/8/3/b83930a7517364cefbe62a647a9aa0facd3da85d.png)

* * *

I hope I can replicate it on here, trying now.

_Poll ([view on site](https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845/1))_

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](https://github.com/discourse/discourse/commits/a3d61ba1c43931eb688f9b2b85c207b5bab02b8c))

Not sure if it matters but I have `poll edit window mins` set to 90 mins

---

<div class="post-metadata">

### Author: ![Vaping\_Community](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vaping_community/32/89248_2.png) [@Vaping\_Community](https://meta.discourse.org/u/Vaping_Community)
#### Post date: [August 9, 2024, 6:43am UTC](https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845/2 "2024-08-09T06:43:40Z")

</div>

Tested with version 3.4.0.beta1-dev and it works fine

Tested with `poll edit windows mins` set to 90

```plaintext
[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](https://meta.discourse.org/t/53504?silent=true)?

```plaintext
http://discourse.example.com/safe-mode

```

---

<div class="post-metadata">

### Author: ![piffy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/piffy/32/254198_2.png) [@piffy](https://meta.discourse.org/u/piffy)
#### Post date: [August 9, 2024, 6:44am UTC](https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845/3 "2024-08-09T06:44:53Z")

</div>

I tried in [safe mode](https://meta.discourse.org/t/53504?silent=true) with no themes (and replicated the issue) but unfortunately I can’t try with no plugins because the polling is a plugin

---

<div class="post-metadata">

### Author: ![Vaping\_Community](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vaping_community/32/89248_2.png) [@Vaping\_Community](https://meta.discourse.org/u/Vaping_Community)
#### Post date: [August 9, 2024, 6:46am UTC](https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845/4 "2024-08-09T06:46:30Z")

</div>

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

```plaintext
[poll name=pollA type=regular results=on_close public=true chartType=bar]
* Option
[/poll]

```

## Error

```plaintext
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '0b05a21ff916fbd0f86b5172a2817610')

```

## Possibly related to

```plaintext
name=pollA 

```

---

<div class="post-metadata">

### Author: ![Vaping\_Community](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vaping_community/32/89248_2.png) [@Vaping\_Community](https://meta.discourse.org/u/Vaping_Community)
#### Post date: [August 9, 2024, 6:51am UTC](https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845/5 "2024-08-09T06:51:30Z")

</div>

@piffy Try this

```plaintext
[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

---

<div class="post-metadata">

### Author: ![piffy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/piffy/32/254198_2.png) [@piffy](https://meta.discourse.org/u/piffy)
#### Post date: [August 9, 2024, 7:03am UTC](https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845/6 "2024-08-09T07:03:42Z")

</div>

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

```plaintext
[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

```plaintext
[poll name=pollC type=regular results=always public=true chartType=bar]
* Option
[/poll]

```

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 9, 2024, 7:14am UTC](https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845/7 "2024-08-09T07:14:03Z")

</div>

Thanks for the report. I’ll take a look.

---

<div class="post-metadata">

### Author: ![Vaping\_Community](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vaping_community/32/89248_2.png) [@Vaping\_Community](https://meta.discourse.org/u/Vaping_Community)
#### Post date: [August 9, 2024, 7:59am UTC](https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845/8 "2024-08-09T07:59:26Z")

</div>

Tested this

```plaintext
[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](https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845/4)

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 9, 2024, 8:14am UTC](https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845/9 "2024-08-09T08:14:56Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 9, 2024, 10:15am UTC](https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845/10 "2024-08-09T10:15:09Z")

</div>

PR raised here:

[https://github.com/discourse/discourse/pull/28299](https://github.com/discourse/discourse/pull/28299)

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 13, 2024, 10:41am UTC](https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845/11 "2024-08-13T10:41:01Z")

</div>

This has been merged, please confirm all is now resolved.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [August 17, 2024, 7:00am UTC](https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845/12 "2024-08-17T07:00:33Z")

</div>

This topic was automatically closed after 3 days. New replies are no longer allowed.
