fix: aria-label warnings for edit profile form

This commit is contained in:
Simon Emanuelsson
2024-04-16 12:59:58 +02:00
parent 21a839488a
commit 4ee4570373
11 changed files with 20 additions and 19 deletions

View File

@@ -2,7 +2,6 @@ import { redirect } from "next/navigation"
import { overview } from "@/constants/routes/myPages" import { overview } from "@/constants/routes/myPages"
import type { Lang } from "@/constants/languages"
import type { LangParams, PageArgs } from "@/types/params" import type { LangParams, PageArgs } from "@/types/params"
export default function MyPages({ params }: PageArgs<LangParams>) { export default function MyPages({ params }: PageArgs<LangParams>) {

View File

@@ -1,3 +0,0 @@
export default function Default() {
return null
}

View File

@@ -1,3 +0,0 @@
export default function Default() {
return null
}

View File

@@ -1,3 +0,0 @@
export default function Default() {
return null
}

View File

@@ -1,3 +0,0 @@
export default function Default() {
return null
}

View File

@@ -1,3 +0,0 @@
export default function Default() {
return null
}

View File

@@ -58,6 +58,7 @@ export default function FormContent({ control }: EditFormContentProps) {
<Field.Label htmlFor="email">*{_("Email")}</Field.Label> <Field.Label htmlFor="email">*{_("Email")}</Field.Label>
<Field.Content> <Field.Content>
<Input <Input
aria-label={_("Email")}
control={control} control={control}
name="email" name="email"
placeholder={_("Email")} placeholder={_("Email")}
@@ -84,6 +85,7 @@ export default function FormContent({ control }: EditFormContentProps) {
<Field.Label htmlFor="street">*{_("Address")}</Field.Label> <Field.Label htmlFor="street">*{_("Address")}</Field.Label>
<Field.Content> <Field.Content>
<Input <Input
aria-label={_("Street")}
control={control} control={control}
name="street" name="street"
placeholder={_("Street 123")} placeholder={_("Street 123")}
@@ -99,6 +101,7 @@ export default function FormContent({ control }: EditFormContentProps) {
<Field.Label htmlFor="city">*{_("City/State")}</Field.Label> <Field.Label htmlFor="city">*{_("City/State")}</Field.Label>
<Field.Content> <Field.Content>
<Input <Input
aria-label={_("City")}
control={control} control={control}
name="city" name="city"
placeholder={_("City")} placeholder={_("City")}
@@ -114,6 +117,7 @@ export default function FormContent({ control }: EditFormContentProps) {
<Field.Label htmlFor="zip">*{_("Zip code")}</Field.Label> <Field.Label htmlFor="zip">*{_("Zip code")}</Field.Label>
<Field.Content> <Field.Content>
<Input <Input
aria-label={_("Zip code")}
control={control} control={control}
name="zip" name="zip"
placeholder={_("Zip code")} placeholder={_("Zip code")}

View File

@@ -62,6 +62,7 @@ export default function CountrySelect({
return ( return (
<div className={styles.container} ref={divRef}> <div className={styles.container} ref={divRef}>
<ComboBox <ComboBox
aria-label={_("Select country of residence")}
className={styles.select} className={styles.select}
isRequired={!!registerOptions?.required} isRequired={!!registerOptions?.required}
name={field.name} name={field.name}
@@ -71,7 +72,11 @@ export default function CountrySelect({
selectedKey={selectedKey} selectedKey={selectedKey}
> >
<div className={styles.comboBoxContainer}> <div className={styles.comboBoxContainer}>
<Input className={styles.input} placeholder={_(placeholder)} /> <Input
aria-label="Selected country"
className={styles.input}
placeholder={_(placeholder)}
/>
<Button className={styles.button}> <Button className={styles.button}>
<SelectChevron /> <SelectChevron />
</Button> </Button>
@@ -91,7 +96,7 @@ export default function CountrySelect({
*/ */
UNSTABLE_portalContainer={divElement ?? undefined} UNSTABLE_portalContainer={divElement ?? undefined}
> >
<ListBox aria-label="Country of residence"> <ListBox>
{countries.map((country, idx) => ( {countries.map((country, idx) => (
<ListBoxItem <ListBoxItem
aria-label={country.name} aria-label={country.name}

View File

@@ -18,6 +18,7 @@ import styles from "./select.module.css"
import type { SelectProps } from "./select" import type { SelectProps } from "./select"
export default function Select({ export default function Select({
"aria-label": ariaLabel,
items, items,
label, label,
name, name,
@@ -41,6 +42,7 @@ export default function Select({
return ( return (
<div className={styles.date} ref={divRef}> <div className={styles.date} ref={divRef}>
<ReactAriaSelect <ReactAriaSelect
aria-label={ariaLabel}
className={styles.select} className={styles.select}
onSelectionChange={handleOnSelect} onSelectionChange={handleOnSelect}
placeholder={placeholder} placeholder={placeholder}
@@ -63,7 +65,7 @@ export default function Select({
*/ */
UNSTABLE_portalContainer={divElement ?? undefined} UNSTABLE_portalContainer={divElement ?? undefined}
> >
<ListBox aria-label={name} className={styles.listBox}> <ListBox className={styles.listBox}>
{items.map((item) => ( {items.map((item) => (
<ListBoxItem <ListBoxItem
aria-label={String(item)} aria-label={String(item)}

View File

@@ -51,6 +51,7 @@ export default function DateSelect({
return ( return (
<DatePicker <DatePicker
aria-label="Select date of birth"
granularity="day" granularity="day"
isRequired={!!registerOptions.required} isRequired={!!registerOptions.required}
name={name} name={name}
@@ -73,6 +74,7 @@ export default function DateSelect({
return ( return (
<DateSegment className={styles.day} segment={segment}> <DateSegment className={styles.day} segment={segment}>
<Select <Select
aria-label={_("Day")}
items={days} items={days}
label={_("Day")} label={_("Day")}
name={DateName.date} name={DateName.date}
@@ -86,6 +88,7 @@ export default function DateSelect({
return ( return (
<DateSegment className={styles.month} segment={segment}> <DateSegment className={styles.month} segment={segment}>
<Select <Select
aria-label={_("Month")}
items={months} items={months}
label={_("Month")} label={_("Month")}
name={DateName.month} name={DateName.month}
@@ -99,6 +102,7 @@ export default function DateSelect({
return ( return (
<DateSegment className={styles.year} segment={segment}> <DateSegment className={styles.year} segment={segment}>
<Select <Select
aria-label={_("Year")}
items={years} items={years}
label={_("Year")} label={_("Year")}
name={DateName.year} name={DateName.year}

View File

@@ -9,6 +9,7 @@ import styles from "./input.module.css"
import type { InputProps } from "./input" import type { InputProps } from "./input"
export default function Input({ export default function Input({
"aria-label": ariaLabel,
control, control,
disabled, disabled,
name, name,
@@ -24,6 +25,7 @@ export default function Input({
return ( return (
<TextField <TextField
aria-label={ariaLabel}
defaultValue={field.value} defaultValue={field.value}
isDisabled={disabled ?? field.disabled} isDisabled={disabled ?? field.disabled}
isInvalid={fieldState.invalid} isInvalid={fieldState.invalid}