Skip to content

Commit

Permalink
96894 - fix active state on navlink tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
jquispe-oddball committed Dec 27, 2024
1 parent 69ecbd7 commit b21807b
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react';
import { useLoaderData, NavLink, Outlet } from 'react-router-dom';
import { useLoaderData, NavLink, Outlet, useLocation } from 'react-router-dom';
import { apiRequest } from '@department-of-veterans-affairs/platform-utilities/api';
import mockPOARequestsResponse from '../mocks/mockPOARequestsResponse.json';
import DigitalSubmissionAlert from '../components/DigitalSubmissionAlert/DigitalSubmissionAlert';

const POARequestsPage = () => {
const poaRequests = useLoaderData();

const { search } = useLocation();
const status = new URLSearchParams(search).get('status');
return (
<>
<h1 data-testid="poa-requests-heading">Power of attorney requests</h1>
Expand All @@ -21,7 +22,11 @@ const POARequestsPage = () => {
<div role="tablist" className="poa-request__tabs">
<NavLink
to="/poa-requests?status=pending"
className="poa-request__tab-link"
className={({ isActive }) =>
isActive && status === 'pending'
? 'poa-request__tab-link active'
: 'poa-request__tab-link'
}
role="tab"
aria-controls="panel-pending"
id="pending"
Expand All @@ -30,10 +35,15 @@ const POARequestsPage = () => {
</NavLink>
<NavLink
to="/poa-requests?status=completed"
className="poa-request__tab-link"
className={({ isActive }) =>
isActive && status === 'completed'
? 'poa-request__tab-link active'
: 'poa-request__tab-link'
}
role="tab"
aria-controls="panel-completed"
id="completed"
ariaSelected={({ isActive }) => (isActive ? 'true' : 'false')}
>
Completed requests
</NavLink>
Expand Down

0 comments on commit b21807b

Please sign in to comment.