@@ -3,7 +3,7 @@ import { ResultsViewer } from "components/ResultsViewer";
33import { Button , Heading , PageContainer , Question } from "components/styles" ;
44import { Field , Form , Formik } from "formik" ;
55import type React from "react" ;
6- import { createRef , useState } from "react" ;
6+ import { createRef , useId , useState } from "react" ;
77import type { QuestionFormat } from "server/src/dbschema/interfaces" ;
88import type {
99 ShowingQuestionState ,
@@ -36,8 +36,8 @@ type QuestionSettingPageState = GetStatesUnion<
3636 typeof QuestionSettingPageState . enum
3737> ;
3838const QuestionSettingPageState = makeStates ( "qsps" , {
39- loading : state < { } > ( ) ,
40- ended : state < { } > ( ) ,
39+ loading : state ( ) ,
40+ ended : state ( ) ,
4141 setQuestion : state < QuestionSettingData > ( ) ,
4242 askingQuestion : state < QuestionAskingData > ( ) ,
4343} ) ;
@@ -163,6 +163,10 @@ const getId = () => id++;
163163function SetQuestion ( { data } : { data : QuestionSettingData } ) {
164164 const [ submitting , setSubmitting ] = useState ( false ) ;
165165
166+ const questionTypeSelectId = useId ( ) ;
167+ const questionTitleInputId = useId ( ) ;
168+ const maxResultsInputId = useId ( ) ;
169+
166170 const onSubmit = async ( values : FormValues ) => {
167171 setSubmitting ( true ) ;
168172
@@ -234,7 +238,10 @@ function SetQuestion({ data }: { data: QuestionSettingData }) {
234238 disabled = { submitting }
235239 className = "gap-4 w-full flex flex-col justify-center items-center"
236240 >
237- < label className = "form-control w-full mt-8 mb-2" >
241+ < label
242+ className = "form-control w-full mt-8 mb-2"
243+ htmlFor = { questionTitleInputId }
244+ >
238245 < div className = "label" >
239246 < span className = "label-text" > Question</ span >
240247 </ div >
@@ -244,10 +251,14 @@ function SetQuestion({ data }: { data: QuestionSettingData }) {
244251 name = "question"
245252 value = { form . values . question }
246253 onChange = { form . handleChange }
254+ id = { questionTitleInputId }
247255 />
248256 </ label >
249257 < div className = "flex gap-2 w-full" >
250- < label className = "form-control mb-8 grow" >
258+ < label
259+ className = "form-control mb-8 grow"
260+ htmlFor = { questionTypeSelectId }
261+ >
251262 < div className = "label" >
252263 < span className = "label-text" > Question Type</ span >
253264 </ div >
@@ -257,14 +268,18 @@ function SetQuestion({ data }: { data: QuestionSettingData }) {
257268 name = "questionType"
258269 value = { form . values . questionType }
259270 onChange = { form . handleChange }
271+ id = { questionTypeSelectId }
260272 >
261273 < option value = "SingleVote" > Single vote</ option >
262274 < option value = "PreferentialVote" >
263275 Preferential vote
264276 </ option >
265277 </ Field >
266278 </ label >
267- < label className = "form-control mb-8" >
279+ < label
280+ className = "form-control mb-8"
281+ htmlFor = { maxResultsInputId }
282+ >
268283 < div className = "label" >
269284 < span className = "label-text" > Max Results</ span >
270285 </ div >
@@ -275,6 +290,7 @@ function SetQuestion({ data }: { data: QuestionSettingData }) {
275290 value = { form . values . maxElected }
276291 onChange = { form . handleChange }
277292 disabled = { form . values . questionType === "SingleVote" }
293+ id = { maxResultsInputId }
278294 />
279295 </ label >
280296 </ div >
@@ -289,7 +305,7 @@ function SetQuestion({ data }: { data: QuestionSettingData }) {
289305 value = { candidate . name }
290306 onChange = { form . handleChange }
291307 ref = { ( el ) => {
292- // Unfortunately any is necessary here, because current is set to readonly in react
308+ // biome-ignore lint/suspicious/noExplicitAny: Unfortunately any is necessary here, because current is set to readonly in react
293309 ( candidate . inputRef as any ) . current = el ;
294310
295311 if ( candidate . forceSelect ) {
0 commit comments