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 2 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
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 @@ -50,6 +50,7 @@ const TitleBox: React.FC<Props> = ({
variant={variantTitle}
display="inline-block"
sx={{ verticalAlign: 'middle' }}
aria-label={`${title}-page`}
Copy link
Contributor

Choose a reason for hiding this comment

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

aria-labels on typography are wrongs, because the screen reader reads the text twice. Maybe the problem is on the typography variant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in the windows os screen reader not read without that

Copy link
Contributor

Choose a reason for hiding this comment

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

mmm it is not the correct way to fix the bug

Copy link
Contributor Author

@leleOFA leleOFA Nov 7, 2024

Choose a reason for hiding this comment

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

which is?

Copy link
Contributor

Choose a reason for hiding this comment

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

try on your own

>
{title}
</Typography>
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 @@ -20,10 +20,10 @@ vi.mock('react-i18next', () => ({

describe('testing profile page', () => {
it('profile page renders properly', () => {
const { getByRole, getByText } = render(<Profile />, {
const { 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 = getByText('title');
expect(title).toBeInTheDocument();
const subtitle = getByText('subtitle');
expect(subtitle).toBeInTheDocument();
Expand Down