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

Fix a11y for contacts page - PN-12920 #1369

Closed
wants to merge 5 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const AppStatusRender: React.FC<Props> = ({
</ApiErrorWrapper>

{/* Titolo elenco di downtime */}
<Typography variant="h6" sx={{ mt: '36px', mb: 2 }}>
<Typography variant="h6" sx={{ mt: '36px', mb: 2 }} tabIndex={-1}>
{downtimeListTitle}
</Typography>

Expand Down
1 change: 1 addition & 0 deletions packages/pn-commons/src/components/TitleBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const TitleBox: React.FC<Props> = ({
variant={variantTitle}
display="inline-block"
sx={{ verticalAlign: 'middle' }}
tabIndex={-1}
>
{title}
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const DeliveryModeStatistics: React.FC<Props> = ({

return (
<Paper sx={{ ...sx, p: 3, mb: 3 }} elevation={0} data-testid="deliveryMode">
<Typography variant="h6" component="h3">
<Typography variant="h6" component="h3" tabIndex={-1}>
{t('delivery_mode.title')}
</Typography>
<Typography sx={{ my: 3 }} variant="body1" color="text.primary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const DigitalErrorsDetailStatistics: React.FC<Props> = ({ data: sData }) => {
<Paper sx={{ p: 3, mb: 3 }} elevation={0} data-testid="digitalErrorsDetail">
<Grid container direction={{ lg: 'row', xs: 'column' }} spacing={3}>
<Grid item lg={5} xs={12} sx={{ p: { xs: 0, lg: 3 } }}>
<Typography variant="h6" component="h3">
<Typography variant="h6" component="h3" tabIndex={-1}>
{t('digital_errors_detail.title')}
</Typography>
<Typography sx={{ my: 3 }} variant="body1" color="text.primary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const DigitalMeanTimeStatistics: React.FC<Props> = (props) => {

return (
<Paper sx={{ ...props.sx, p: 3, mb: 3 }} elevation={0} data-testid="digitalMeanTimeContainer">
<Typography variant="h6" component="h3">
<Typography variant="h6" component="h3" tabIndex={-1}>
{t('digital_mean_time.title')}
</Typography>
<Typography sx={{ my: 3 }} variant="body1" color="text.primary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const DigitalStateStatistics: React.FC<Props> = (props) => {

return (
<Paper sx={{ ...props.sx, p: 3, mb: 3 }} elevation={0} data-testid="digitalStateContainer">
<Typography variant="h6" component="h3">
<Typography variant="h6" component="h3" tabIndex={-1}>
{t('digital_state.title')}
</Typography>
<Typography sx={{ my: 3 }} variant="body1" color="text.primary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const FiledNotificationsStatistics: React.FC<Props> = ({
<Paper sx={{ p: 3, mb: 3 }} elevation={0} data-testid="filedNotifications">
<Grid container direction={direction} spacing={spacing}>
<Grid item lg={5} xs={12} sx={{ p: { xs: 0, lg: 3 } }}>
<Typography variant="h6" component="h3">
<Typography variant="h6" component="h3" tabIndex={-1}>
{t('filed.title')}
</Typography>
<Typography sx={{ my: 3 }} variant="body1" color="text.primary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const LastStateStatistics: React.FC<Props> = (props) => {

return (
<Paper sx={{ ...props.sx, p: 3, mb: 3 }} elevation={0} data-testid="lastStateContainer">
<Typography variant="h6" component="h3">
<Typography variant="h6" component="h3" tabIndex={-1}>
{t('last_state.title')}
</Typography>
<Typography sx={{ my: 3 }} variant="body1" color="text.primary">
Expand Down
2 changes: 1 addition & 1 deletion packages/pn-pa-webapp/src/pages/ApiKeys.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const ApiKeys = () => {
marginTop: isMobile ? 3 : 10,
}}
>
<Typography variant="h5" sx={{ marginBottom: isMobile ? 3 : undefined }}>
<Typography variant="h5" sx={{ marginBottom: isMobile ? 3 : undefined }} tabIndex={-1}>
{t('generated-api-keys')}
</Typography>
<Button
Expand Down
4 changes: 2 additions & 2 deletions packages/pn-pa-webapp/src/pages/Statistics.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const Statistics = () => {
{getLastUpdateText()}
</Typography>
<Box ref={exportJpgNode}>
<Typography variant="h6" component="h5" mt={7}>
<Typography variant="h6" component="h5" mt={7} tabIndex={-1}>
{t('section_1')}
</Typography>

Expand Down Expand Up @@ -179,7 +179,7 @@ const Statistics = () => {
/>
</Grid>
</Grid>
<Typography variant="h6" component="h5" mt={9}>
<Typography variant="h6" component="h5" mt={9} tabIndex={-1}>
{t('section_2')}
</Typography>
<FilterStatistics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ const ContactsSummaryCard: React.FC<ContactsSummaryCardProps> = ({
return t('summary-card.no-address');
}

const contactsType = availableAddresses.reduce((acc, item) => {
// eslint-disable-next-line functional/immutable-data
acc[item.channelType] = t(`summary-card.${item.channelType}`);
return acc;
}, {} as { [key: string]: string });
const contactsType = availableAddresses.reduce(
(acc, item) => {
// eslint-disable-next-line functional/immutable-data
acc[item.channelType] = t(`summary-card.${item.channelType}`);
return acc;
},
{} as { [key: string]: string }
);

return Object.values(contactsType).join(', ');
};
Expand Down Expand Up @@ -89,26 +92,19 @@ const ContactsSummaryCard: React.FC<ContactsSummaryCardProps> = ({
sx={{ width: { xs: '100%', lg: '185px' } }}
data-testid={isCourtesyCard ? 'courtesyContactsCard' : 'legalContactsCard'}
>
<CardActionArea
onClick={goToSection}
sx={{ p: 2 }}
aria-label={t(title)}
aria-description={getDescription()}
>
<CardActionArea onClick={goToSection} sx={{ p: 2 }}>
{getIcon()}
<Typography
variant="body2"
fontWeight={600}
data-testid="cardTitle"
aria-hidden
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be removed. why did you remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on windows the card are not read

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried with windows and also with aria-hidden it was read

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do I restore it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have to understand how to fix the problem. The card is a button so, when user goes on the card, the screen reader should read the content (i.e. the title and the subititle). The aria-hidden is to avoid that screen reader reads the content twice

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with aria-hidden the text 'A valore legale' and 'Di cortesia' are not read by windows voice assistant.

sx={{ mt: 0.5, mb: 1 }}
>
{t(title)}
</Typography>
<Typography
variant="body2"
data-testid="cardDescription"
aria-hidden
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as before

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as before

color={hasAddress ? 'primary' : 'text.secondary'}
>
{getDescription()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const Delegates = () => {
/>
<Box mb={8} data-testid="delegates-wrapper">
<Stack mb={2} direction={'row'} justifyContent={'space-between'} alignItems={'center'}>
<Typography variant="h5">{t('deleghe.delegatesTitle')}</Typography>
<Typography variant="h5" tabIndex={-1}>{t('deleghe.delegatesTitle')}</Typography>
<Box>
<Button
id="add-delegation-button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const Delegators = () => {
return (
<Box mb={8} data-testid="delegators-wrapper">
<Stack mb={2} direction={'row'} justifyContent={'space-between'} alignItems={'center'}>
<Typography variant="h5">{t('deleghe.delegatorsTitle')}</Typography>
<Typography variant="h5" tabIndex={-1}>{t('deleghe.delegatorsTitle')}</Typography>
</Stack>
<ApiErrorWrapper
apiId={DELEGATION_ACTIONS.GET_MANDATES_BY_DELEGATE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('testing profile page', () => {
const { getByRole, getByText } = render(<Profile />, {
preloadedState: { userState: { user: userResponse } },
});
const title = getByRole('heading', { name: 'title' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test failure with that role

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is strange, this should not happen

const title = getByRole('heading', { name: 'title'});
expect(title).toBeInTheDocument();
const subtitle = getByText('subtitle');
expect(subtitle).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const DelegatesByCompany = () => {
justifyContent={'space-between'}
alignItems={isMobile ? 'flex-start' : 'center'}
>
<Typography variant="h6" mb={3}>
<Typography variant="h6" mb={3} tabIndex={-1}>
{t('deleghe.delegatesTitle')}
</Typography>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ const DelegationsOfTheCompany = () => {

return (
<Box data-testid="delegationsOfTheCompany">
<Typography variant="h6" mb={4}>
<Typography variant="h6" mb={4} tabIndex={-1}>
{t('deleghe.delegatorsTitle')}
</Typography>
<ApiErrorWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const PublicKeys: React.FC = () => {
mt: 5,
}}
>
<Typography variant="h6" sx={{ mb: { xs: 3, lg: 0 } }}>
<Typography variant="h6" sx={{ mb: { xs: 3, lg: 0 } }} tabIndex={-1}>
{t('publicKeys.title')}
</Typography>
{!hasOneActiveKey && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const VirtualKeys: React.FC = () => {
mt: 8,
}}
>
<Typography variant="h6" sx={{ mb: { xs: 3, lg: 0 } }}>
<Typography variant="h6" sx={{ mb: { xs: 3, lg: 0 } }} tabIndex={-1}>
{t('virtualKeys.title')}
</Typography>
{isCreationEnabled && (
Expand Down