Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Päivämääräkentän validointivirhe ruudunlukijalle #6163

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion frontend/src/citizen-frontend/calendar/AbsenceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,18 @@ export default React.memo(function AbsenceModal({
</TabletAndDesktop>
</LineContainer>
<CalendarModalSection>
<H2>{i18n.calendar.absenceModal.dateRange}</H2>
<H2 id="absence-daterange-label">
{i18n.calendar.absenceModal.dateRange}
</H2>
<DateRangePickerF
bind={range}
locale={lang}
hideErrorsBeforeTouched={!showAllErrors}
onFocus={(ev) => {
scrollIntoViewSoftKeyboard(ev.target, 'start')
}}
required
ariaId="absence-daterange-label"
/>
<Gap size="s" />
<P noMargin>{i18n.calendar.absenceModal.selectChildrenInfo}</P>
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/citizen-frontend/calendar/ReservationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ export default React.memo(function ReservationModal({
}
inlineChildren
>
<Label>{i18n.calendar.reservationModal.dateRangeLabel}</Label>
<Label id="reservation-daterange-label">
{i18n.calendar.reservationModal.dateRangeLabel}
</Label>
</ExpandingInfo>
<DateRangePickerF
bind={dateRange}
Expand All @@ -264,6 +266,8 @@ export default React.memo(function ReservationModal({
onFocus={(ev) => {
scrollIntoViewSoftKeyboard(ev.target, 'start')
}}
required
ariaId="reservation-daterange-label"
/>

{overlappingClosedHolidayPeriods.length > 0 && (
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/lib-components/atoms/form/InputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ const InputField = React.memo(function InputField({
step={step}
id={id}
aria-describedby={ariaId}
aria-invalid={infoStatus === 'warning'}
aria-required={required ?? false}
required={required ?? false}
ref={inputRef}
autoFocus={autoFocus}
Expand All @@ -334,7 +336,10 @@ const InputField = React.memo(function InputField({
)}
{!!infoText && (
<InputFieldUnderRow className={classNames(infoStatus)}>
<span data-qa={dataQa ? `${dataQa}-info` : undefined}>
<span
data-qa={dataQa ? `${dataQa}-info` : undefined}
role={infoStatus === 'warning' ? 'alert' : undefined}
>
{infoText}
</span>
<UnderRowStatusIcon status={info?.status} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const DateRangePicker = React.memo(function DateRangePicker({
export default DateRangePicker

export const DatePickerSpacer = React.memo(function DatePickerSpacer() {
return <DateInputSpacer>–</DateInputSpacer>
return <DateInputSpacer aria-hidden>–</DateInputSpacer>
})

const DateInputSpacer = styled.div`
Expand All @@ -157,6 +157,7 @@ export interface DateRangePickerFProps
> {
bind: BoundForm<LocalDateRangeField>
info?: InputInfo | undefined
ariaId?: string
}

export const DateRangePickerF = React.memo(function DateRangePickerF({
Expand Down Expand Up @@ -197,7 +198,10 @@ export const DateRangePickerF = React.memo(function DateRangePickerF({
/>
{info !== undefined && (!hideErrorsBeforeTouched || touched) ? (
<InputFieldUnderRow className={classNames(info.status)}>
<span>{info.text}</span> <UnderRowStatusIcon status={info.status} />
<span role={info.status === 'warning' ? 'alert' : undefined}>
{info.text}
</span>
<UnderRowStatusIcon status={info.status} />
</InputFieldUnderRow>
) : null}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface DateRangePickerLowLevelProps
onChange: (value: [string, string]) => void
startInfo?: InputInfo
endInfo?: InputInfo
ariaId?: string
}

export default React.memo(function DateRangePickerLowLevel({
Expand All @@ -30,6 +31,7 @@ export default React.memo(function DateRangePickerLowLevel({
'data-qa': dataQa,
minDate,
maxDate,
ariaId,
...datePickerProps
}: DateRangePickerLowLevelProps) {
const startDate = useMemo(() => LocalDate.parseFiOrNull(start), [start])
Expand Down Expand Up @@ -68,7 +70,7 @@ export default React.memo(function DateRangePickerLowLevel({
)

return (
<FixedSpaceRow data-qa={dataQa}>
<FixedSpaceRow data-qa={dataQa} aria-labelledby={ariaId} role="group">
<DatePickerLowLevel
value={start}
onChange={handleChangeStart}
Expand Down
Loading