diff --git a/src/components/views/elements/PollCreateDialog.tsx b/src/components/views/elements/PollCreateDialog.tsx index 3d987c3d96..653d69864d 100644 --- a/src/components/views/elements/PollCreateDialog.tsx +++ b/src/components/views/elements/PollCreateDialog.tsx @@ -138,7 +138,7 @@ export default class PollCreateDialog extends ScrollableBaseModal a.trim()).filter((a) => !!a), - this.state.kind, + this.state.kind.name, ).serialize(); if (!this.props.editingMxEvent) { diff --git a/test/components/views/elements/PollCreateDialog-test.tsx b/test/components/views/elements/PollCreateDialog-test.tsx index 1459e501fc..fdfb4b50e7 100644 --- a/test/components/views/elements/PollCreateDialog-test.tsx +++ b/test/components/views/elements/PollCreateDialog-test.tsx @@ -252,6 +252,25 @@ describe("PollCreateDialog", () => { }, }); }); + + it("retains poll disclosure type when editing", () => { + const previousEvent: MatrixEvent = new MatrixEvent( + PollStartEvent.from("Poll Q", ["Answer 1", "Answer 2"], M_POLL_KIND_DISCLOSED).serialize(), + ); + previousEvent.event.event_id = "$prevEventId"; + + const dialog = mount( + , + ); + + changeValue(dialog, "Question or topic", "Poll Q updated"); + dialog.find("button").simulate("click"); + + const [, , eventType, sentEventContent] = mockClient.sendEvent.mock.calls[0]; + expect(M_POLL_START.matches(eventType)).toBeTruthy(); + // didnt change + expect(sentEventContent["m.new_content"][M_POLL_START.name].kind).toEqual(M_POLL_KIND_DISCLOSED.name); + }); }); function createRoom(): Room {