Skip to content

Commit

Permalink
Merge pull request #2459 from HHS/main
Browse files Browse the repository at this point in the history
[Prod] Fix markup (Accessibility improvements)
  • Loading branch information
Jones-QuarteyDana authored Nov 5, 2024
2 parents d23d7cb + 5844a53 commit 06e0675
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 21 deletions.
23 changes: 23 additions & 0 deletions frontend/src/components/AvatarGroup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import PropTypes from 'prop-types';
import Avatar from './Avatar';

const AvatarGroup = ({ userName, className }) => (
<h2 className={`margin-0 display-flex flex-align-center border-bottom border-gray-10 ${className}`}>
<Avatar name={userName} />
<span className="margin-left-2 font-sans-xs">
{userName}
</span>
</h2>
);

AvatarGroup.propTypes = {
userName: PropTypes.string.isRequired,
className: PropTypes.string,
};

AvatarGroup.defaultProps = {
className: 'padding-2',
};

export default AvatarGroup;
2 changes: 1 addition & 1 deletion frontend/src/components/FeedArticle.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const FeedArticle = ({
return (
<article className={`${className} position-relative margin-bottom-3 padding-bottom-3 ${unread ? 'ttahub-feed-article--unread' : ''}`}>
<div className="ttahub-feed-article-content position-relative maxw-tablet">
<h4 className="ttahub-feed-article-title usa-prose margin-0 padding-0">{title}</h4>
{title && (<h4 className="ttahub-feed-article-title usa-prose margin-0 padding-0">{title}</h4>)}
{parse(content)}
</div>
</article>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/FileUploader/DeleteFileModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const DeleteFileModal = ({
modalId="DeleteFileModal"
title="Delete File"
okButtonText="Delete"
okButtonAriaLabel="This button will permanently delete the file."
okButtonAriaLabel="Confirm delete"
>
<p>
Are you sure you want to delete
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/FileUploader/FileTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ const FileTable = ({ onFileRemoved, files }) => {
<th width="20%">
Status
</th>
<th width="10%" aria-label="remove file" />

<th width="10%">
<span className="usa-sr-only">Remove file</span>
</th>
</tr>
</thead>
<tbody>
Expand Down
21 changes: 11 additions & 10 deletions frontend/src/components/HeaderUserMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faUpRightFromSquare } from '@fortawesome/free-solid-svg-icons';
import { useLocation } from 'react-router-dom';
import Avatar from './Avatar';
import AvatarGroup from './AvatarGroup';
import DropdownMenu from './DropdownMenu';
import './HeaderUserMenu.scss';
import NavLink from './NavLink';
Expand All @@ -19,8 +20,10 @@ function UserMenuNav({ items }) {
return (
<div>
<ul className="user-menu-nav">
{items.map(({ key, element, liClass }) => (
<li key={key} className={liClass}>
{items.map(({
key, element, liClass, presentation,
}) => (
<li key={key} className={liClass} role={presentation ? 'presentation' : 'listitem'}>
{element}
</li>
))}
Expand All @@ -33,6 +36,7 @@ UserMenuNav.propTypes = {
items: PropTypes.arrayOf(PropTypes.shape({
key: PropTypes.number,
element: PropTypes.element,
presentation: PropTypes.bool,
})).isRequired,
};

Expand Down Expand Up @@ -105,12 +109,13 @@ function HeaderUserMenu({ areThereUnreadNotifications, setAreThereUnreadNotifica
fn = onItemClick,
}) => {
if (showIfAdmin && !userIsAdmin) return false;
if (divider) return { key, element: <hr /> };
if (space) return { key, element: <div className="height-6" /> };
if (divider) return { key, presentation: true, element: <hr /> };
if (space) return { key, presentation: true, element: <div aria-hidden="true" className="height-6" /> };

if (external) {
return {
key,
presentation: false,
element: (
<Link key={key} className="usa-nav__link" href={to} target="_blank" rel="noopener noreferrer">
<span>{label}</span>
Expand All @@ -123,6 +128,7 @@ function HeaderUserMenu({ areThereUnreadNotifications, setAreThereUnreadNotifica

return {
key,
presentation: false,
element: (
<>
<NavLink key={key} to={to} fn={fn}>
Expand Down Expand Up @@ -195,12 +201,7 @@ function HeaderUserMenu({ areThereUnreadNotifications, setAreThereUnreadNotifica
className="no-print"
>
<div className="user-menu-dropdown" data-testid="user-menu-dropdown">
<h4 className="margin-0 display-flex flex-align-center padding-2 border-bottom border-gray-10">
<Avatar name={user.name} />
<span className="margin-left-2">
{user.name}
</span>
</h4>
<AvatarGroup userName={user.name} />
{isImpersonating && (
<div className="display-flex flex-justify-center margin-top-2">
<Button type="button" onClick={stopImpersonating}>
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/pages/AccountManagement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {

import { useForm, FormProvider, useFormContext } from 'react-hook-form';
import { useParams } from 'react-router';
import Avatar from '../../components/Avatar';
import UserContext from '../../UserContext';
import {
subscribe,
Expand All @@ -29,6 +28,7 @@ import EmailVerifier from './EmailVerifier';
import Groups from './components/Groups';
import WidgetCard from '../../components/WidgetCard';
import WidgetHeader from '../../components/WidgetHeader';
import AvatarGroup from '../../components/AvatarGroup';

const emailPreferenceErrorMessage = 'Please select a frequency preference';

Expand Down Expand Up @@ -381,10 +381,7 @@ function AccountManagement({ updateUser }) {
<WidgetCard header={<WidgetHeader>Profile</WidgetHeader>}>
{/* Avatar w/ name */}
<div className="margin-bottom-3">
<h4 className="margin-0 display-flex flex-align-center padding-bottom-3 border-bottom border-gray-20">
<Avatar name={user.name} />
<span className="margin-left-2">{user.name}</span>
</h4>
<AvatarGroup userName={user.name} className="padding-bottom-3" />
</div>

{/* Last login */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ describe('sessionSummary', () => {
fetchMock.delete(deleteUrl, 200);

const confirmDelete = await screen.findByRole('button', {
name: /This button will permanently delete the file/i,
name: /confirm delete/i,
});

act(() => {
Expand Down Expand Up @@ -335,7 +335,7 @@ describe('sessionSummary', () => {
fetchMock.delete(deleteUrl, 500);

const confirmDelete = await screen.findByRole('button', {
name: /This button will permanently delete the file/i,
name: /confirm delete/i,
});

act(() => {
Expand Down

0 comments on commit 06e0675

Please sign in to comment.