Skip to content

Commit

Permalink
🚸 ErrorSummary i UtenlandsPeriodeVelger
Browse files Browse the repository at this point in the history
  • Loading branch information
tidnav committed May 28, 2024
1 parent ec0ca1c commit 309d06c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/input/MonthPickerWrapper/MonthPickerWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const MonthPickerWrapper = ({
dropdownCaption={dropdownCaption}
defaultSelected={selectedDate}
>
<MonthPicker.Input {...inputProps} label={label} error={error} />
<MonthPicker.Input {...inputProps} id={id} label={label} error={error} />
</MonthPicker>
);
};
4 changes: 2 additions & 2 deletions components/input/countryselector/CountrySelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ const CountrySelector = ({ name, label, className, onChange, value, error }: Pro
return Object.entries(countries.getNames('nb', { select: 'official' }))
.filter((country) => country[0] !== 'NO' && country[0] !== 'SJ')
.sort(
(a, b) => (a[1] > b[1] ? 1 : -1) // Sorterer alfabetisk på navn i stedet for landkode
(a, b) => (a[1] > b[1] ? 1 : -1), // Sorterer alfabetisk på navn i stedet for landkode
);
}, [countries]);

return (
<div className={className}>
<Select name={name} label={label} onChange={onChange} value={value} error={error}>
<Select id={name} name={name} label={label} onChange={onChange} value={value} error={error}>
{[
<option key="none" value="none">
Velg land
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
.pidInput input {
max-width: 8rem;
}
.visuallyHidden {
composes: visuallyHidden from '/styles/visibility.module.css';
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
BodyLong,
BodyShort,
Button,
ErrorSummary,
Heading,
HGrid,
Label,
Expand Down Expand Up @@ -160,6 +161,20 @@ const UtenlandsPeriodeVelger = ({
}
}}
>
<ErrorSummary
heading={formatMessage({ id: 'errorSummary.title' })}
aria-hidden={!errors?.length}
className={errors?.length ? '' : classes?.visuallyHidden}
tabIndex={0}
>
{errors?.length
? errors.map((error) => (
<ErrorSummary.Item key={error.path} href={`#${error.path}`}>
{error.message}
</ErrorSummary.Item>
))
: 'hidden'}
</ErrorSummary>
<CountrySelector
className={classes.countrySelector}
name={'land'}
Expand Down

0 comments on commit 309d06c

Please sign in to comment.