-
Notifications
You must be signed in to change notification settings - Fork 319
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(homepage): a11y errors #1483
Changes from 9 commits
9a73792
d6eeaf1
73dc138
e9a2636
1d2b644
2ee9a60
212de8a
365f6eb
2c07563
b1222e5
1a16af5
ca834d4
94bb127
b948437
20f84aa
dde5608
7a40db3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
'@aws-amplify/ui-react': patch | ||
'@aws-amplify/ui': patch | ||
--- | ||
|
||
- fix a11y erros on docs homepage | ||
- fix type errors | ||
- rename css class |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import { CopyToClipboard } from 'react-copy-to-clipboard'; | |
|
||
import { Button } from '@aws-amplify/ui-react'; | ||
|
||
export const Copy = ({ text, size, variation }) => { | ||
export const Copy = ({ text, size, variation, className }) => { | ||
const [copied, setCopied] = React.useState(false); | ||
|
||
const copy = () => { | ||
|
@@ -15,7 +15,12 @@ export const Copy = ({ text, size, variation }) => { | |
|
||
return ( | ||
<CopyToClipboard text={text} onCopy={copy}> | ||
<Button size={size} variation={variation} isLoading={copied}> | ||
<Button | ||
size={size} | ||
variation={variation} | ||
isLoading={copied} | ||
className={className} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add |
||
> | ||
{copied ? 'Copied!' : 'Copy'} | ||
</Button> | ||
</CopyToClipboard> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,6 +113,7 @@ export const Header = ({ platform, colorMode, setColorMode }) => { | |
<Button | ||
className="docs-header-menu-button" | ||
onClick={() => setExpanded(!expanded)} | ||
aria-label="Docs header menu button" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we may eventually use variables for aria-label for i18n. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use ariaLabel instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
> | ||
{expanded ? <IconClose /> : <IconMenu />} | ||
</Button> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ const getCSPContent = (context: Readonly<HtmlProps>) => { | |
class MyDocument extends Document { | ||
render() { | ||
return ( | ||
<Html> | ||
<Html lang="en-us"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we may eventually use variables for lang There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you create a ticket for the docs for a language switcher if it doesn't already exist? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<Head> | ||
<meta | ||
httpEquiv="Content-Security-Policy" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ import { HomePrimitivePreview } from './HomePrimitivePreview'; | |
import { Copy } from '@/components/Copy'; | ||
import { Footer } from '@/components/Layout/Footer'; | ||
|
||
import type { SandpackThemeProp } from '@codesandbox/sandpack-react'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI, we are going to remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. potentially... there are some potential security issues with it since it uses |
||
|
||
const code = `import { AmplifyProvider, Button, Card, Text, Heading, Flex, Badge, Image, StepperField, useTheme } from '@aws-amplify/ui-react'; | ||
import '@aws-amplify/ui-react/styles.css'; | ||
|
||
|
@@ -100,7 +102,7 @@ const HomePage = ({ colorMode, setThemeOverride, themeOverride }) => { | |
const router = useRouter(); | ||
const { tokens } = useTheme(); | ||
const framework = (router.query.platform as string) ?? 'react'; | ||
const sandPackTheme = { | ||
const sandPackTheme: SandpackThemeProp = { | ||
palette: { | ||
activeText: `${tokens.colors.font.interactive}`, | ||
defaultText: `${tokens.colors.font.secondary}`, | ||
|
@@ -133,7 +135,6 @@ const HomePage = ({ colorMode, setThemeOverride, themeOverride }) => { | |
monoFont: | ||
'"Fira Mono", "DejaVu Sans Mono", Menlo, Consolas, "Liberation Mono", Monaco, "Lucida Console", monospace', | ||
fontSize: '16px', | ||
lineHeight: '1.5', | ||
reesscot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
}; | ||
const installScripts = { | ||
|
@@ -170,16 +171,17 @@ const HomePage = ({ colorMode, setThemeOverride, themeOverride }) => { | |
Get started | ||
<IconChevronRight /> | ||
</Button> | ||
<TextField | ||
label="" | ||
labelHidden={true} | ||
isReadOnly={true} | ||
className="install-code" | ||
outerEndComponent={ | ||
<Copy variation="link" text={frameworkInstallScript} /> | ||
} | ||
value={frameworkInstallScript} | ||
/> | ||
<code className="install-code__container"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
<p className="install-code__content"> | ||
{frameworkInstallScript} | ||
</p> | ||
<Copy | ||
className="install-code__button" | ||
size="" | ||
variation="link" | ||
text={frameworkInstallScript} | ||
/> | ||
</code> | ||
</Flex> | ||
</Card> | ||
<Flex | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ export function SignIn() { | |
className="amplify-flex" | ||
disabled={isPending} | ||
> | ||
<legend>Sign in</legend> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes this will change the design of Authenticator. It would be better if you can ping them to take a look at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this fix an accessibility issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, there's an alert that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot to add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, adding visually-hidden should be sufficient. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. Added |
||
<UserNameAlias | ||
labelHidden={userOverrides?.labelHidden} | ||
placeholder={userOverrides?.placeholder} | ||
|
@@ -100,6 +101,7 @@ export function SignIn() { | |
|
||
SignIn.Header = (): JSX.Element => null; | ||
SignIn.Footer = () => { | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not disable rules of hooks here. There are a handful of rules of hooks violations in Authenticator which need to be dealt with and I don't want to have to find them manually. |
||
const { toResetPassword } = useAuthenticator(); | ||
|
||
// Support backwards compatibility for legacy key with trailing space | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ const MenuPrimitive: Primitive<MenuProps, 'div'> = ( | |
<DropdownMenuTrigger asChild={true}> | ||
{trigger ?? ( | ||
<MenuButton | ||
role="button" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure why we need to add it for a button, so removed it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did it cause an accessibility error? I vaguely remember that without There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, it doesn't cause any a11y error because it is a button. It would cause error if it's a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tested it and the menu button still works correctly. Proceed 👍 |
||
ariaLabel="menu button" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we want to add a standard ariaLabel here. Remember, this will apply for all customers using the Menu. We may need to consider adding an external prop to set this label. To solve the "missing label" problem, you could pass in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! Done |
||
size={size} | ||
testId={MENU_TRIGGER_TEST_ID} | ||
className={classNames( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,9 @@ export const RatingIcon: React.FC<RatingIconProps> = ({ | |
className, | ||
}) => { | ||
return ( | ||
<View as="span" className={classNames(`amplify-rating-icon-container`)}> | ||
<View as="label" className={classNames(`amplify-rating-label`)}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure what's the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'm not sure why there's a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the label tag was a remnant of earlier designs when this component was not read only. Looking at some other rating components out there they use a label and hidden checkbox to mark user selections. @reesscot brought up a good point that we could have customers who are targeting this label for styling and so if we don't need to remove it, then it would be best to leave it in. @0618 other than the extra clutter, was the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jacoblogan yes, "empty label" is a type of a11y error, so I removed it but kept the class selector in this PR. Is that ok? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. If it's causing a11y error let's remove it. |
||
<View as="span" className={classNames(className)} color={fill}> | ||
{icon} | ||
</View> | ||
<View as="span" className="amplify-rating-icon-container"> | ||
<View as="span" className={classNames(className)} color={fill}> | ||
{icon} | ||
</View> | ||
</View> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,29 +19,29 @@ export const RatingMixedIcon: React.FC<RatingMixedIconProps> = ({ | |
}) => { | ||
const widthPercentage = `${(value % 1) * 100}%`; | ||
return ( | ||
<View as="span" className={classNames(`amplify-rating-icon-container`)}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure why we need |
||
<View as="label" className={classNames(`amplify-rating-label`)}> | ||
<View as="span" className="amplify-rating-icon-container"> | ||
<View as="span" className="amplify-rating-icon-place"> | ||
<View | ||
as="span" | ||
className={classNames( | ||
`amplify-rating-icon`, | ||
`amplify-rating-icon-empty` | ||
'amplify-rating-icon', | ||
'amplify-rating-icon-empty' | ||
)} | ||
color={emptyColor} | ||
> | ||
{emptyIcon} | ||
</View> | ||
</View> | ||
<View | ||
as="label" | ||
className={classNames(`amplify-rating-label`)} | ||
as="span" | ||
className="amplify-rating-icon-place" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't change this classname There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
width={widthPercentage} | ||
> | ||
<View | ||
as="span" | ||
className={classNames( | ||
`amplify-rating-icon`, | ||
`amplify-rating-icon-filled` | ||
'amplify-rating-icon', | ||
'amplify-rating-icon-filled' | ||
)} | ||
color={fillColor} | ||
> | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -50,6 +50,7 @@ const SliderFieldPrimitive: Primitive<SliderFieldProps, typeof Root> = ( | |||||
const fieldId = useStableId(id); | ||||||
const labelId = useStableId(); | ||||||
const descriptionId = useStableId(); | ||||||
const ariaDescribedBy = labelHidden ? labelId : descriptionId; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also add a unit test for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
NVM, I missed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, can we please split these changes out into a separate PR, as we will need to make these changes in all the Field components that use the |
||||||
|
||||||
const { flexContainerStyleProps, rest } = splitPrimitiveProps(_rest); | ||||||
|
||||||
|
@@ -133,7 +134,7 @@ const SliderFieldPrimitive: Primitive<SliderFieldProps, typeof Root> = ( | |||||
/> | ||||||
</Track> | ||||||
<Thumb | ||||||
aria-describedby={descriptionId} | ||||||
aria-describedby={ariaDescribedBy} | ||||||
aria-labelledby={labelId} | ||||||
aria-valuetext={ariaValuetext} | ||||||
className={ComponentClassNames.SliderFieldThumb} | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,8 @@ const TextFieldPrimitive = <Multiline extends boolean>( | |
|
||
const fieldId = useStableId(id); | ||
const descriptionId = useStableId(); | ||
const labelId = useStableId(); | ||
const ariaDescribedBy = labelHidden ? labelId : descriptionId; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm guessing this is indented to fix an accessibility error where the description text is missing when I'm seeing two accessibility issues here:
I think the behavior should actually be changed to something like the following to fix these issues:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree @reesscot's fixes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, agree! Thanks for the findings here and fixing this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated! Converted the change and hide |
||
|
||
const { flexContainerStyleProps, baseStyleProps, rest } = | ||
splitPrimitiveProps(_rest); | ||
|
@@ -61,7 +63,7 @@ const TextFieldPrimitive = <Multiline extends boolean>( | |
const { rows } = props; | ||
control = ( | ||
<TextArea | ||
aria-describedby={descriptionId} | ||
aria-describedby={ariaDescribedBy} | ||
hasError={hasError} | ||
id={fieldId} | ||
ref={isTextAreaRef(props, ref) ? ref : undefined} | ||
|
@@ -75,7 +77,7 @@ const TextFieldPrimitive = <Multiline extends boolean>( | |
const { type = 'text' } = props; | ||
control = ( | ||
<Input | ||
aria-describedby={descriptionId} | ||
aria-describedby={ariaDescribedBy} | ||
hasError={hasError} | ||
id={fieldId} | ||
ref={isInputRef(props, ref) ? ref : undefined} | ||
|
@@ -98,7 +100,7 @@ const TextFieldPrimitive = <Multiline extends boolean>( | |
testId={testId} | ||
{...flexContainerStyleProps} | ||
> | ||
<Label htmlFor={fieldId} visuallyHidden={labelHidden}> | ||
<Label htmlFor={fieldId} visuallyHidden={labelHidden} id={labelId}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this? the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed. |
||
{label} | ||
</Label> | ||
<FieldDescription | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,4 +49,9 @@ export interface ButtonProps extends ViewProps, FlexContainerStyleProps { | |
* Changes the visual weight of the button. | ||
*/ | ||
variation?: ButtonVariations; | ||
|
||
/** | ||
* Changes href of the button. | ||
*/ | ||
href?: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about this change. Most buttons are not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are using it in some places on the docs site where we do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1.. Should we just use an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! I think we should not use buttons as anchor or vice versa. I'll remove the type change here and add a ticket for refactor. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. Revert change. Cut a ticket to use |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,17 +7,18 @@ | |
box-shadow: var(--amplify-components-card-box-shadow); | ||
display: inline-block; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Anyone know why cards are inline-block? Seems like they should just be display: block, then you wouldn't need the width:100%. @dbanksdesign thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing this is a breaking change as well I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Changed to |
||
padding: var(--amplify-components-card-padding); | ||
|
||
&[data-variation="outlined"] { | ||
width: 100%; | ||
|
||
&[data-variation='outlined'] { | ||
background-color: var(--amplify-components-card-outlined-background-color); | ||
border-radius: var(--amplify-components-card-outlined-border-radius); | ||
border-width: var(--amplify-components-card-outlined-border-width); | ||
border-style: var(--amplify-components-card-outlined-border-style); | ||
border-color: var(--amplify-components-card-outlined-border-color); | ||
box-shadow: var(--amplify-components-card-outlined-box-shadow); | ||
} | ||
&[data-variation="elevated"] { | ||
|
||
&[data-variation='elevated'] { | ||
background-color: var(--amplify-components-card-elevated-background-color); | ||
border-radius: var(--amplify-components-card-elevated-border-radius); | ||
border-width: var(--amplify-components-card-elevated-border-width); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ | |
width: 1em; | ||
} | ||
|
||
.amplify-rating-label { | ||
.amplify-rating-icon-place { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we can rename classnames without a breaking change, since customers could be depending on them. These files affect customer apps and not just the docs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, making changes to class name are breaking changes. I believe my demo app has use some of the classnames for custom styling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted back. |
||
position: absolute; | ||
overflow: hidden; | ||
height: 1em; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the new attributes being added and the structure of some of the components being updated do we want this to be a minor bump instead of a patch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point...
I checked the semver doc
Since we don't have any new features in this PR, I think it's not a MUST.