Skip to content

Commit e89755f

Browse files
authored
ST2936 polls: fix PollQuestion deletion bug (#1806)
1 parent 57a04ad commit e89755f

5 files changed

Lines changed: 17 additions & 9 deletions

File tree

adhocracy4/polls/static/PollDashboard/EditPollChoice.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import React from 'react'
22
import django from 'django'
33
import FormFieldError from '../../../static/FormFieldError'
44

5-
export const EditPollChoice = (props) => {
5+
export const EditPollChoice = React.forwardRef((props, ref) => {
66
return (
7-
<div className="form-group">
7+
<div className="form-group" ref={ref}>
88
<div htmlFor={'id_choices-' + props.id + '-name'}>
99
{django.pgettext('noun', 'Answer')} {props.index}
1010
{props.choiceId &&
@@ -43,4 +43,6 @@ export const EditPollChoice = (props) => {
4343
/>
4444
</div>
4545
)
46-
}
46+
})
47+
48+
EditPollChoice.displayName = 'EditPollChoice'

adhocracy4/polls/static/PollDashboard/EditPollManagement.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ export const EditPollManagement = (props) => {
242242
? (
243243
<EditPollOpenQuestion
244244
id={key}
245+
key={key}
245246
question={question}
246247
onLabelChange={(label) => handleQuestionLabel(index, label)}
247248
onHelptextChange={(helptext) => handleQuestionHelpText(index, helptext)}
@@ -254,6 +255,7 @@ export const EditPollManagement = (props) => {
254255
: (
255256
<EditPollQuestion
256257
id={key}
258+
key={key}
257259
question={question}
258260
onLabelChange={(label) => handleQuestionLabel(index, label)}
259261
onHelptextChange={(helptext) => handleQuestionHelpText(index, helptext)}

adhocracy4/polls/static/PollDashboard/EditPollOpenQuestion.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import django from 'django'
33
import FormFieldError from '../../../static/FormFieldError'
44
import { HelptextForm } from './HelptextForm'
55

6-
export const EditPollOpenQuestion = (props) => {
6+
export const EditPollOpenQuestion = React.forwardRef((props, ref) => {
77
const [hasHelptext, setHasHelptext] = useState(props.question.help_text)
88

99
return (
10-
<section className="editpoll__question-container">
10+
<section ref={ref} className="editpoll__question-container">
1111
<div className="editpoll__question">
1212
<div className="editpoll__question--border">
1313
<div className="form-group">
@@ -80,4 +80,6 @@ export const EditPollOpenQuestion = (props) => {
8080
</div>
8181
</section>
8282
)
83-
}
83+
})
84+
85+
EditPollOpenQuestion.displayName = 'EditPollOpenQuestion'

adhocracy4/polls/static/PollDashboard/EditPollQuestion.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { HelptextForm } from './HelptextForm'
66

77
const FlipMove = require('react-flip-move').default
88

9-
export const EditPollQuestion = (props) => {
9+
export const EditPollQuestion = React.forwardRef((props, ref) => {
1010
const [hasHelptext, setHasHelptext] = useState(props.question.help_text)
1111
const hasOtherOption = props.question.choices.find(c => c.is_other_choice)
1212
return (
13-
<section className="editpoll__question-container">
13+
<section ref={ref} className="editpoll__question-container">
1414
<div className="editpoll__question">
1515
<div className="form-group editpoll__question--border">
1616
<label
@@ -162,4 +162,6 @@ export const EditPollQuestion = (props) => {
162162
</div>
163163
</section>
164164
)
165-
}
165+
})
166+
167+
EditPollQuestion.displayName = 'EditPollQuestion'

changelog/2936.md

Whitespace-only changes.

0 commit comments

Comments
 (0)