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

feat(AdvancedDataCard): support for href/to #859

Merged
merged 35 commits into from
Nov 16, 2023

Conversation

brunocezar-tlf
Copy link
Contributor

PR for Advanced Data Card accessibility testing

@github-actions
Copy link

github-actions bot commented Aug 22, 2023

Size stats

master this branch diff
Total JS 9.58 MB 9.58 MB +1.21 kB
JS without icons 1.02 MB 1.02 MB +1.21 kB
Lib overhead 126 kB 126 kB 0 B
Lib overhead (gzip) 32.1 kB 32.1 kB 0 B

@github-actions
Copy link

github-actions bot commented Aug 22, 2023

Deploy preview for mistica-web ready!

✅ Preview
https://mistica-qjp7nfg9b-tuentisre.vercel.app

Built with commit 08777c2.
This pull request is being automatically deployed with vercel-action

@github-actions
Copy link

github-actions bot commented Aug 22, 2023

Accessibility report
✔️ No issues found

ℹ️ You can run this locally by executing yarn audit-accessibility.

@github-actions
Copy link

github-actions bot commented Aug 22, 2023

Screenshot tests report

✔️ All passing

@@ -289,6 +281,7 @@ export const AdvancedDataCard = React.forwardRef<HTMLDivElement, AdvancedDataCar
maybe
className={classNames(styles.touchableContainer, {[styles.hoverEffect]: !!onPress})}
aria-label={ariaLabel}
role="link"
Copy link
Contributor

Choose a reason for hiding this comment

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

why role link?
Touchable renders as html <button> (role button) when used with onPress prop and as html <a> (role link) when used with href/to prop . If you want a link, I think the best approach is adding href/to support to AdvancedDataCard as we have in other cards

Choose a reason for hiding this comment

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

Hello Abel,

This PR is still under review of accessibility team, we upload here to generate the preview link for them.
Most grateful for your contribution at this time :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the role='link' was to be able to adjust the accessibility semantics without changing any properties, but I implemented the href according to your suggestion

@EduardoLafuente EduardoLafuente marked this pull request as ready for review October 6, 2023 13:39
@brunocezar-tlf brunocezar-tlf changed the title Accessibility Advanced Data Card feat(DataCard Advanced): fix Accesibility Oct 6, 2023
@@ -2343,7 +2343,7 @@ const advancedDataCardSnippets = [
}
footerText="footer text"
onClose={() => window.alert("close")}
onPress={() => window.alert("click")}
href="asdf"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
href="asdf"
href="https://google.com"

Copy link
Contributor

Choose a reason for hiding this comment

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

this is not expected, is 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.

was not expected, but the slightly larger size is due to the touchable being moved into the internal component that encompasses pretitle, title etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

just curious, my focus of the review is not this kind of technical details but I would like to understand why the replacement of onPress by href and does not support both properties (like the rest of the cards)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for changing from onPress to href is due to the screen reader, with onPress it would be read as a button, while href as a link which would be more suitable for accessibility

@brunocezar-tlf brunocezar-tlf changed the title feat(DataCard Advanced): fix Accesibility Fix(DataCard Advanced): Accessibility Oct 6, 2023
href={href}
aria-label={ariaLabel}
>
<div />
Copy link
Contributor

Choose a reason for hiding this comment

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

what's this empty div? and why are you creating an empty link (Touchable)?

Copy link
Contributor Author

@brunocezar-tlf brunocezar-tlf Oct 11, 2023

Choose a reason for hiding this comment

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

The empty div is because the touchable must have a child, and the reason the touchable is there is so the touchable does not interfere with the screen reader's reading order.

Touchable is a link, as it must be read as such in the screen reader, where it receives the link from the href prop previously as onPress.

@@ -38,9 +38,18 @@ export const actions = style([
},
]);

export const touchableAccessibility = style({
Copy link
Contributor

Choose a reason for hiding this comment

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

please use a more semantic name

@@ -95,6 +103,8 @@ export const cardContentStyle = style([
},
]);

export const zindex = style({zIndex: -20});
Copy link
Contributor

Choose a reason for hiding this comment

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

why -20?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The negative z-index is so that images in slots (like SimpleBlock) don't overlap the Touchable

Copy link
Contributor

Choose a reason for hiding this comment

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

this number doesn't make sense to me. I'm sure you can reorder the elements, use different stacking contexts or using a more sensible zIndex value than -20

Comment on lines 204 to 211
onPress?: () => void;
href?: string | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a breaking change, we should avoid breaking changes, otherwise we'd need to generate a major version. Also why don't you support href/onPress/to as we do with other cards?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change from onPress to href is so that on the screen reader it can be read as a link instead of a button.

Choose a reason for hiding this comment

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

Hi @atabel,
Is something pending on our side?

Copy link
Contributor

@yceballost yceballost Oct 25, 2023

Choose a reason for hiding this comment

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

We can't make a major version just for this breaking change, we need to support onPress + href, and we also can include to to have parity with the rest of the cards. But we need to keep onPress because in master is already existing and there are teams using this prop.

@EduardoLafuente @BrunoGuimaraes103

@brunocezar-tlf brunocezar-tlf requested a review from atabel October 16, 2023 20:24
@@ -95,6 +103,8 @@ export const cardContentStyle = style([
},
]);

export const zindex = style({zIndex: -20});
Copy link
Contributor

Choose a reason for hiding this comment

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

this number doesn't make sense to me. I'm sure you can reorder the elements, use different stacking contexts or using a more sensible zIndex value than -20

@@ -261,7 +290,7 @@ export const AdvancedDataCard = React.forwardRef<HTMLDivElement, AdvancedDataCar
},
ref
) => {
const isTouchable = !!onPress;
const isTouchable = !!href || !!onPress;
Copy link
Contributor

Choose a reason for hiding this comment

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

what about to ?

tabIndex={0}
maybe
className={classNames(styles.touchableArea)}
as="a"
Copy link
Contributor

Choose a reason for hiding this comment

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

not needed, Touchable renders an <a> when used with href or to

Comment on lines 229 to 231
onPress?: () => void;
href?: string | undefined;
to?: undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

to/href/onPress shouldn't be allowed at the same time. You can use ExclusifyUnion to help you with this.
Please, review how we do the same in other mistica cards: https://github.com/Telefonica/mistica-web/blob/master/src/card.tsx#L416-L425

@brunocezar-tlf brunocezar-tlf requested a review from atabel November 8, 2023 16:35
Comment on lines 230 to 232
onPress?: () => void;
href?: string | undefined;
to?: undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

remove to/href/onPress from common props, you are already defining them in the ExclusifyUnion

@@ -43,9 +46,13 @@ type CardContentProps = {
subtitleLinesMax?: number;
description?: string;
descriptionLinesMax?: number;
href?: string;
to?: undefined;
Copy link
Contributor

@atabel atabel Nov 15, 2023

Choose a reason for hiding this comment

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

to shouldn't be undefined here.
You should use ExclusifyUnion here too, like you do in AdvancedDataCardProps

Comment on lines 76 to 98
{href ? (
<Touchable
tabIndex={0}
maybe
className={classNames(styles.touchableArea)}
href={href}
to={to}
aria-label={ariaLabel}
>
<div />
</Touchable>
) : (
<Touchable
tabIndex={0}
maybe
className={classNames(styles.touchableArea)}
onPress={onPress}
to={to}
aria-label={ariaLabel}
>
{title}
</Text>
<div />
</Touchable>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

@atabel atabel changed the title Fix(DataCard Advanced): Accessibility feat(AdvancedDataCard): support for href/to Nov 15, 2023
@atabel atabel added this pull request to the merge queue Nov 16, 2023
Merged via the queue into master with commit ba5eafb Nov 16, 2023
@atabel atabel deleted the accessibility-advanced-data-card branch November 16, 2023 16:19
tuentisre pushed a commit that referenced this pull request Nov 16, 2023
# [14.32.0](v14.31.1...v14.32.0) (2023-11-16)

### Bug Fixes

* **ScreenReaderOnly:** Fix ScreenReaderOnly positioning to avoid scrolling issues ([#942](#942)) ([f6537e9](f6537e9))

### Features

* **AdvancedDataCard:** support for href/to ([#859](#859)) ([ba5eafb](ba5eafb))
@tuentisre
Copy link
Collaborator

🎉 This PR is included in version 14.32.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants