Skip to content

Commit

Permalink
Wrap engagement URL copy button in LiveAnnouncer for accessibility, a…
Browse files Browse the repository at this point in the history
…dd index route
  • Loading branch information
NatSquared committed Aug 19, 2024
1 parent 758567f commit 993d964
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 31 deletions.
67 changes: 36 additions & 31 deletions met-web/src/components/engagement/admin/view/ConfigSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import dayjs from 'dayjs';
import { ENGAGEMENT_MEMBERSHIP_STATUS, EngagementTeamMember } from 'models/engagementTeamMember';
import { Button } from 'components/common/Input';
import { faPen } from '@fortawesome/pro-regular-svg-icons';
import { LiveAnnouncer, LiveMessage } from 'react-aria-live';

export const ConfigSummary = () => {
const siteUrl = getBaseUrl();
Expand Down Expand Up @@ -44,37 +45,41 @@ export const ConfigSummary = () => {
</BodyText>
</Grid>
<Grid item>
<Tooltip arrow open={tooltipOpen} title="Copied!" placement="top">
<IconButton
size="small"
sx={{
backgroundColor: 'primary.light',
color: 'white',
width: '32px',
height: '32px',
'&:hover': {
backgroundColor: 'primary.main',
},
...globalFocusVisible,
display: 'inline-block',
marginRight: '0.5rem',
}}
onClick={() => {
navigator.clipboard.writeText(`${siteUrl}/${slug}`);
setTooltipOpen(true);
}}
>
<FontAwesomeIcon
fontSize={16}
icon={faCopy}
style={{ position: 'relative', bottom: '4px' }}
/>
</IconButton>
</Tooltip>
<BodyText sx={{ display: 'inline' }}>
<span style={{ fontWeight: 'bold' }}>{siteUrl}/</span>
{slug}
</BodyText>
<LiveAnnouncer>
<LiveMessage aria-live="assertive" message={tooltipOpen ? 'Copied!' : ''} />
<Tooltip arrow open={tooltipOpen} title="Copied!" placement="top">
<IconButton
size="small"
sx={{
backgroundColor: 'primary.light',
color: 'white',
width: '32px',
height: '32px',
'&:hover': {
backgroundColor: 'primary.main',
},
...globalFocusVisible,
display: 'inline-block',
marginRight: '0.5rem',
}}
onClick={() => {
navigator.clipboard.writeText(`${siteUrl}/${slug}`);
setTooltipOpen(true);
}}
aria-label="Press enter to copy engagement URL to clipboard"
>
<FontAwesomeIcon
fontSize={16}
icon={faCopy}
style={{ position: 'relative', bottom: '4px' }}
/>
</IconButton>
</Tooltip>
<BodyText sx={{ display: 'inline' }}>
<span style={{ fontWeight: 'bold' }}>{siteUrl}/</span>
{slug}
</BodyText>
</LiveAnnouncer>
</Grid>
</Grid>
</OutlineBox>
Expand Down
1 change: 1 addition & 0 deletions met-web/src/routes/AuthenticatedRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const AuthenticatedRoutes = () => {
},
}}
>
<Route index element={<Navigate to="view" />} />
<Route element={<AuthGate allowedRoles={[USER_ROLES.EDIT_ENGAGEMENT]} />}>
<Route path="form" element={<EngagementForm />} />
<Route
Expand Down

0 comments on commit 993d964

Please sign in to comment.