Skip to content

Commit fb6e345

Browse files
committed
Resolve React specific errors for key and nested links.
1 parent f6224ef commit fb6e345

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

src/app/app-routes.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { redirect, RouteObject } from 'react-router-dom';
2-
import ErpHGridView from './views/erp-hgrid/erp-hgrid-view';
2+
import ERPHGridView from './views/erp-hgrid/erp-hgrid-view';
33
import HRPortalView from './views/hr-portal/hr-portal-view';
44
import FinanceView from './views/finance/finance-view';
55
import SalesView from './views/sales/sales-view';
@@ -11,14 +11,14 @@ export const routes: RouteObject[] = [
1111
{ path: 'home', element: <HomeView />,
1212
children: [
1313
{ index: true, loader: () => redirect('inventory') },
14-
{ path: 'inventory', element: <ErpHGridView /> },
14+
{ path: 'inventory', element: <ERPHGridView /> },
1515
{ path: 'hr-portal', element: <HRPortalView /> },
1616
{ path: 'finance', element: <FinanceView />},
1717
{ path: 'sales', element: <SalesView /> },
1818
{ path: 'fleet', element: <FleetManagementView /> },
1919
]
2020
},
21-
{ path: 'inventory', element: <ErpHGridView /> },
21+
{ path: 'inventory', element: <ERPHGridView /> },
2222
{ path: 'hr-portal', element: <HRPortalView /> },
2323
{ path: 'finance', element: <FinanceView />},
2424
{ path: 'sales', element: <SalesView /> },

src/app/views/home/home-view.scss

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,14 @@
129129
}
130130
}
131131

132-
a {
132+
.learn-text {
133+
text-decoration: none;
134+
color: var(--ig-primary-500);
135+
font-size: 14px;
136+
font-weight: 700;
137+
font-family: "aktiv-grotesk", sans-serif;
138+
line-height: 20px;
139+
133140
width: unset;
134141
padding-bottom: 2px;
135142
transition: background-size 350ms;
@@ -154,15 +161,6 @@
154161
}
155162
}
156163

157-
.learn-text {
158-
text-decoration: none;
159-
color: var(--ig-primary-500);
160-
font-size: 14px;
161-
font-weight: 700;
162-
font-family: "aktiv-grotesk", sans-serif;
163-
line-height: 20px;
164-
}
165-
166164
.tooltip {
167165
position: relative;
168166
display: inline-block;

src/app/views/home/home-view.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ interface TabItemProps {
1919
tabInfo?: TabInfo,
2020
}
2121

22+
/* eslint-disable */
23+
2224
export function TabItem({isActive, tabInfo}: TabItemProps) {
2325

2426
function onLinkClick(event: any) {
25-
const targetHTML = event.currentTarget as HTMLAnchorElement;
26-
window.open(targetHTML.href, "_blank")?.focus();
27+
window.open(tabInfo?.moreLink, "_blank")?.focus();
2728
event.preventDefault();
2829
event.stopPropagation();
2930
}
@@ -46,7 +47,7 @@ export function TabItem({isActive, tabInfo}: TabItemProps) {
4647
<span>{tabInfo?.content}</span>
4748
</div>
4849
<div className="tab-actions">
49-
<a className={"learn-text" + (!isActive ? " link--disabled" : "" )} href={tabInfo?.moreLink} onClick={onLinkClick}>Learn more</a>
50+
<span className={"learn-text" + (!isActive ? " link--disabled" : "" )} onClick={onLinkClick}>Learn more</span>
5051
<div className="tooltip">
5152
<IgrIconButton className={"button" + (isActive ? "--enabled" : "--disabled")} onClick={onDownloadClick}>
5253
<IgrRipple key='downloadRipple'></IgrRipple>
@@ -128,9 +129,9 @@ export default function HomeView() {
128129
<div className="demo-container">
129130
<div className="tab-container ">
130131
{['inventory', 'hr-portal', 'finance', 'sales', 'fleet'].map(tabName =>
131-
<NavLink to={`/home/${tabName}`}>
132+
<NavLink key={tabName} to={`/home/${tabName}`}>
132133
{({ isActive }) => (
133-
<TabItem key={tabName} isActive={isActive} tabInfo={tabInfo.get(tabName)}/>
134+
<TabItem isActive={isActive} tabInfo={tabInfo.get(tabName)}/>
134135
)}
135136
</NavLink>
136137
)}

0 commit comments

Comments
 (0)