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

SUR-323 - Accessibility fixes for Force UI components. #189

Merged
merged 53 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
4256261
Initialized accessibility fixes branch
JelenaTakac Nov 5, 2024
da3aaa3
Fixed accessibility violation for Alert component
JelenaTakac Nov 8, 2024
f169840
Fixed accessibility violation for Breadcrumb component
JelenaTakac Nov 8, 2024
9340ab9
Fixed accessibility violation for Progress Bar component
JelenaTakac Nov 11, 2024
65bf5f9
Fixed accessibility violation for Pagination component
JelenaTakac Nov 11, 2024
a69b0dd
Fixed accessibility violation for Datapicker component
JelenaTakac Nov 12, 2024
1b2df14
Merge branch 'SUR-242' into SUR-323/accessibility-fixes
JelenaTakac Nov 12, 2024
1d134b7
Added accessibility fixes for Alert, Breadcrumb, Progress Bar and Dat…
JelenaTakac Nov 12, 2024
60f642e
Fixed 'Buttons must have discernible text' issue for Area, Bar and Pi…
JelenaTakac Nov 12, 2024
4ef3477
fix: Dropdown not visible
jaieds Nov 13, 2024
04323d1
Spread other props to the Avatar
jaieds Nov 13, 2024
29d7209
fix: DropdownMenu component accessibility issues
jaieds Nov 13, 2024
acc1091
Resolved a11y violation "Elements must meet minimum color contrast ra…
JelenaTakac Nov 13, 2024
fd4b4c3
fix: Menu component accessibility issue
jaieds Nov 13, 2024
167ee35
Disabled color contrast accessibility violation
jaieds Nov 13, 2024
bbfaee1
fix: Area & Bar chart accessibility issues
jaieds Nov 13, 2024
d20ad4d
fix: The Tooltip is not visible
jaieds Nov 13, 2024
0141848
Update the test runner config
jaieds Nov 13, 2024
472601e
fix: Cards story accessibility issue
jaieds Nov 13, 2024
48d8a19
fix: Drawer component accessibility issue
jaieds Nov 13, 2024
6779851
fix: Pie chart accessibility issues
jaieds Nov 13, 2024
9e55288
disabled accessibility check for the templates
jaieds Nov 13, 2024
212b4a8
Merge branch 'SUR-323/accessibility-fixes' into SUR-323-Fixes
jaieds Nov 13, 2024
3a2651d
Update Area, bar and pie chart component
jaieds Nov 13, 2024
657d806
disabled editor input component accessibility issue
jaieds Nov 13, 2024
6286479
fix: Pagination component accessibility issues
jaieds Nov 13, 2024
5ba78e6
Fixed Input component a11y violations
JelenaTakac Nov 13, 2024
3452dcd
Fixed Radio Button component a11y violation
JelenaTakac Nov 13, 2024
1076079
Fixed Switch component a11y violation
JelenaTakac Nov 13, 2024
8cab8e9
Fixed TextArea component a11y violation
JelenaTakac Nov 13, 2024
43eb792
Fixed a11y violation for Widget Blocks story in Card component
JelenaTakac Nov 13, 2024
3937cf7
Delete tsconfig.app.tsbuildinfo
jaieds Nov 14, 2024
810e795
Update package-lock.json
jaieds Nov 14, 2024
51cccf6
Merge branch 'SUR-323-Fixes' of github.com:brainstormforce/force-ui i…
jaieds Nov 14, 2024
2f04796
chore: Lint
jaieds Nov 14, 2024
81f666d
Removed sr-only label and added aria-label instead
jaieds Nov 14, 2024
08e5a4a
refactor: Removed extra variable
jaieds Nov 14, 2024
11dd657
refactor: Replaced sr-only label with the aria-label
jaieds Nov 14, 2024
71f1437
Add the role attribute to the breadcrumb separator
jaieds Nov 14, 2024
36757a1
fix: Breadcrumb component accessibility issue
jaieds Nov 14, 2024
acd8600
fix: Menu component accessibility issue
jaieds Nov 14, 2024
8a6cf9b
fix: Select component accessibility issue
jaieds Nov 14, 2024
dd30742
fix: Accessibility issues of templates
jaieds Nov 14, 2024
070dad9
chore: Lint
jaieds Nov 14, 2024
5cb290f
Removed static aria attribute
jaieds Nov 14, 2024
02eb78d
fix: z-index of the dropdown
jaieds Nov 14, 2024
9a8aec1
Removed color contrast ratio ignore rule
jaieds Nov 14, 2024
b8c19df
Update storybook-tests.yml
jaieds Nov 14, 2024
b05a3b4
Removed ignore rule
jaieds Nov 14, 2024
7322063
Ignore rule only for the editor input
jaieds Nov 14, 2024
f6bcde7
fix: Select component transition
jaieds Nov 15, 2024
5401c60
fix: type to search
jaieds Nov 15, 2024
baee63c
Disable color contrast ratio check
jaieds Nov 15, 2024
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
10 changes: 10 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ const preview: Preview = {
date: /Date$/i,
},
},
a11y: {
config: {
rules: [
{
id: 'color-contrast',
enabled: false,
},
],
},
},
vrundakansara marked this conversation as resolved.
Show resolved Hide resolved
},
decorators: [
(Story) => (
Expand Down
22 changes: 19 additions & 3 deletions .storybook/test-runner.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
const { injectAxe, checkA11y } = require('axe-playwright');
const { getStoryContext } = require('@storybook/test-runner');
const { injectAxe, checkA11y, configureAxe } = require('axe-playwright');

module.exports = {
async preVisit(page) {
await injectAxe(page);
},
async postVisit(page) {
await checkA11y(page, '#storybook-root', {
async postVisit(page, context) {
// Get the entire context of a story, including parameters, args, argTypes, etc.
const storyContext = await getStoryContext(page, context);
// Apply story-level a11y rules
await configureAxe(page, {
rules: storyContext.parameters?.a11y?.config?.rules,
});

// Do not run a11y tests on disabled stories.
if (storyContext.parameters?.a11y?.disable) {
return;
}

const element =
storyContext.parameters?.a11y?.element ?? '#storybook-root';
await checkA11y(page, element, {
detailedReport: true,
detailedReportOptions: {
html: true,
},
rules: [{ 'color-contrast': { enabled: false } }],
});
vrundakansara marked this conversation as resolved.
Show resolved Hide resolved
},
};
490 changes: 245 additions & 245 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/components/alert/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const Alert = ( {
closeIconClassNames.light
) }
onClick={ () => closeAlert() }
aria-label="Close alert"
>
<X />
</button>
Expand Down Expand Up @@ -157,6 +158,7 @@ const Alert = ( {
closeIconClassNames.light
) }
onClick={ () => closeAlert() }
aria-label="Close alert"
>
<X />
</button>
Expand Down
2 changes: 2 additions & 0 deletions src/components/area-chart/area-chart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export const AreaChartCard1: Story1 = ( args ) => (
</Label>
<Button className="p-0" variant="ghost">
<ArrowUpRight className="text-icon-secondary size-4" />
<span className="sr-only">View Details</span>
</Button>
</Container>
<Container containerType="flex" align="center" gap="xs">
Expand Down Expand Up @@ -267,6 +268,7 @@ export const AreaChartCard2: Story1 = ( args ) => (
</Label>
<Button className="p-0" variant="ghost">
<ArrowUpRight className="text-icon-secondary size-4" />
<span className="sr-only">View Details</span>
</Button>
</Container>
<Container containerType="flex" align="center" gap="xs">
Expand Down
2 changes: 1 addition & 1 deletion src/components/area-chart/area-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const AreaChart = ( {
xAxisDataKey,
yAxisDataKey,
xAxisFontSize = 'sm', // sm, md, lg
xAxisFontColor = '#4B5563',
xAxisFontColor = '#6B7280',
chartWidth = 350,
chartHeight = 200,
}: AreaChartProps ) => {
Expand Down
2 changes: 2 additions & 0 deletions src/components/avatar/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const Avatar = forwardRef<Ref, AvatarProps>(
alt,
children,
className,
...props
},
ref
) => {
Expand Down Expand Up @@ -116,6 +117,7 @@ const Avatar = forwardRef<Ref, AvatarProps>(
{ ...( textAvatar
? { children: getChildren() }
: { src: url, alt, onError: handleImageError } ) }
{ ...props }
/>
);
}
Expand Down
5 changes: 5 additions & 0 deletions src/components/bar-chart/bar-chart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ export const BarChartCard1: Story1 = ( args ) => (
</Label>
<Button className="p-0" variant="ghost">
<ArrowUpRight className="text-icon-secondary size-4" />
<span className="sr-only">View Details</span>
</Button>
</Container>
<Container containerType="flex" align="center" gap="xs">
Expand Down Expand Up @@ -321,6 +322,7 @@ export const BarChartCard2: Story1 = ( args ) => (
</Label>
<Button className="p-0" variant="ghost">
<ArrowUpRight className="text-icon-secondary size-4" />
<span className="sr-only">View Details</span>
</Button>
</Container>
<Container containerType="flex" align="center" gap="xs">
Expand Down Expand Up @@ -385,6 +387,7 @@ export const BarChartCard3: Story1 = ( args ) => (
</Label>
<Button className="p-0" variant="ghost">
<ArrowUpRight className="text-icon-secondary size-4" />
<span className="sr-only">View Details</span>
</Button>
</Container>
<Container containerType="flex" align="center" gap="xs">
Expand Down Expand Up @@ -450,6 +453,7 @@ export const BarChartCard4: Story1 = ( args ) => (
</Label>
<Button className="p-0" variant="ghost">
<ArrowUpRight className="text-icon-secondary size-4" />
<span className="sr-only">View Details</span>
</Button>
</Container>
<Container containerType="flex" align="center" gap="xs">
Expand Down Expand Up @@ -514,6 +518,7 @@ export const AreaChartCard5: Story1 = ( args ) => (
</Label>
<Button className="p-0" variant="ghost">
<ArrowUpRight className="text-icon-secondary size-4" />
<span className="sr-only">View Details</span>
</Button>
</Container>
<Container containerType="flex" align="center" gap="xs">
Expand Down
4 changes: 2 additions & 2 deletions src/components/bar-chart/bar-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ const BarChart = ( {
xAxisDataKey,
yAxisDataKey,
xAxisFontSize = 'sm', // sm, md, lg
xAxisFontColor = '#4B5563',
yAxisFontColor = '#4B5563',
xAxisFontColor = '#6B7280',
yAxisFontColor = '#6B7280',
chartWidth = 350,
chartHeight = 200,
borderRadius = 8,
Expand Down
4 changes: 2 additions & 2 deletions src/components/breadcrumb/breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ export const BreadcrumbSeparator = ( { type }: BreadcrumbSeparatorProps ) => {
};

return (
<span className="flex items-center text-text-tertiary mx-2">
<li className="flex items-center text-text-tertiary mx-2">
vrundakansara marked this conversation as resolved.
Show resolved Hide resolved
{ separatorIcons[ type ] || separatorIcons.arrow }
</span>
</li>
);
};
BreadcrumbSeparator.displayName = 'Breadcrumb.Separator';
Expand Down
1 change: 1 addition & 0 deletions src/components/cards/plugin-blocks.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const Template2 = ( args: Template2Props ) => {
<Container.Item className="items-center">
<Button className="p-0" variant="ghost">
<ArrowUpRight />
<span className="sr-only">View Details</span>
</Button>
</Container.Item>
</Container>
Expand Down
1 change: 1 addition & 0 deletions src/components/cards/widget-blocks.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ const Template1 = ( args: Template1Props ) => {
<Button variant="ghost" className="p-0 leading-none ">
{ ' ' }
<Ellipsis />
<span className="sr-only">Option</span>
</Button>
</Container.Item>
</Container>
Expand Down
2 changes: 2 additions & 0 deletions src/components/datepicker/datepicker-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ const DatePickerComponent = ( {
variant="ghost"
onClick={ handlePrevButtonClick }
className="bg-background-primary border-none cursor-pointer"
aria-label="Previous Button"
>
<ChevronLeft className="h-4 w-4" />
</Button>
Expand Down Expand Up @@ -226,6 +227,7 @@ const DatePickerComponent = ( {
variant="ghost"
onClick={ handleNextButtonClick }
className="bg-background-primary border-none cursor-pointer"
aria-label="Next Button"
>
<ChevronRight className="h-4 w-4" />
</Button>
Expand Down
4 changes: 3 additions & 1 deletion src/components/drawer/drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ const Drawer = ( {
'fixed z-auto w-0 h-0 overflow-visible',
className
) }
role="dialog"
ref={ drawerContainerRef }
role="dialog"
aria-modal="true"
aria-label="drawer"
>
{ children }
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/components/dropdown-menu/dropdown-menu.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const AvatarTrigger: Story = ( args ) => (
<DropdownMenu { ...args } placement="bottom-start">
<DropdownMenu.Trigger>
<Avatar>John</Avatar>
<span className="sr-only">Open Menu</span>
</DropdownMenu.Trigger>
<DropdownMenu.Content className="w-60">
<DropdownMenu.List>
Expand All @@ -67,6 +68,7 @@ export const IconTrigger: Story = ( args ) => (
<DropdownMenu { ...args } placement="bottom-end">
<DropdownMenu.Trigger>
<House />
<span className="sr-only">Open Menu</span>
</DropdownMenu.Trigger>
<DropdownMenu.Content className="w-60">
<DropdownMenu.List>
Expand Down
72 changes: 42 additions & 30 deletions src/components/dropdown-menu/dropdown-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, {
cloneElement,
Fragment,
isValidElement,
type ReactNode,
type ReactElement,
} from 'react';
import {
useFloating,
Expand Down Expand Up @@ -39,8 +39,8 @@ export const DropdownMenu = ( {
placement = 'bottom',
offset: offsetValue = 10,
boundary = 'clippingAncestors',
dropdownPortalRoot = null,
dropdownPortalId = '',
dropdownPortalRoot,
dropdownPortalId,
children,
className,
}: DropdownMenuProps ) => {
Expand Down Expand Up @@ -83,27 +83,23 @@ export const DropdownMenu = ( {
return (
<DropdownMenuContext.Provider value={ { handleClose } }>
<div className={ cn( 'relative inline-block', className ) }>
<div
ref={ refs.setReference }
onClick={ toggleMenu }
role="button"
tabIndex={ 0 }
{ ...getReferenceProps() }
className="cursor-pointer"
>
{ React.Children.map( children, ( child ) => {
if (
(
child as ReactNode & {
type: { displayName: string };
}
)?.type?.displayName === 'DropdownMenu.Trigger'
) {
return child;
}
return null;
} ) }
</div>
{ React.Children.map( children, ( child ) => {
if (
React.isValidElement( child ) &&
(
child as ReactElement & {
type: { displayName: string };
}
)?.type?.displayName === 'DropdownMenu.Trigger'
) {
return cloneElement( child as ReactElement, {
ref: refs.setReference,
onClick: toggleMenu,
...getReferenceProps(),
} );
}
return null;
} ) }

{ isMounted && (
<FloatingPortal
Expand All @@ -121,7 +117,7 @@ export const DropdownMenu = ( {
{ React.Children.map( children, ( child ) => {
if (
(
child as ReactNode & {
child as ReactElement & {
type?: { displayName: string };
}
)?.type?.displayName ===
Expand All @@ -144,11 +140,27 @@ DropdownMenu.displayName = 'DropdownMenu';
export const DropdownMenuTrigger = React.forwardRef<
HTMLDivElement,
DropdownCommonProps
>( ( { children, className }, ref ) => (
<div ref={ ref } role="button" tabIndex={ 0 } className={ className }>
{ children }
</div>
) );
>( ( { children, className, ...props }, ref ) => {
if ( isValidElement( children ) ) {
return React.cloneElement( children as React.ReactElement, {
className,
ref,
...props,
} );
}

return (
<div
ref={ ref }
className={ cn( 'cursor-pointer', className ) }
role="button"
tabIndex={ 0 }
{ ...props }
>
{ children }
</div>
);
} );

DropdownMenuTrigger.displayName = 'DropdownMenu.Trigger';

Expand Down
7 changes: 7 additions & 0 deletions src/components/editor-input/editor-input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ const meta: Meta<typeof EditorInput> = {
title: 'Atoms/EditorInput',
component: EditorInput,
tags: [ 'autodocs' ],
parameters: {
a11y: {
config: {
rules: [ { id: 'aria-input-field-name', enabled: false } ],
},
},
},
decorators: [
( Story ) => (
<div
Expand Down
Loading
Loading