Skip to content

Commit f73612e

Browse files
committed
fixed web metrics hover error
1 parent 6addc91 commit f73612e

File tree

3 files changed

+51
-6
lines changed

3 files changed

+51
-6
lines changed

src/app/components/StateRoute/PerformanceVisx/BarGraph.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
127127
<label id='routes-dropdown'>Route: </label>
128128
<select
129129
className='performance-dropdown'
130-
labelId='demo-simple-select-label'
130+
labelid='demo-simple-select-label'
131131
id='routes-select'
132132
onChange={(e) => {
133133
setRoute(e.target.value);
@@ -147,7 +147,7 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
147147
<form className='routesForm' id='routes-formcontrol'>
148148
<label id='routes-dropdown'>Snapshot: </label>
149149
<select
150-
labelId='demo-simple-select-label'
150+
labelid='demo-simple-select-label'
151151
id='snapshot-select'
152152
onChange={(e) => setSnapshot(e.target.value)}
153153
>

src/app/components/StateRoute/WebMetrics/WebMetrics.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,15 @@ const radialGraph = (props) => {
103103
}
104104
};
105105

106+
const hoverOptions = {
107+
followCursor: false,
108+
shiftX: 20,
109+
shiftY: 0,
110+
};
111+
106112
return (
107113
<div className='metric'>
108-
<ReactHover>
114+
<ReactHover options={hoverOptions}>
109115
<Trigger type='trigger'>
110116
<div id='chart' className='chart-container'>
111117
<Charts

src/app/containers/ErrorContainer.tsx

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React from 'react';
1+
import React, { useEffect } from 'react';
22
import { useDispatch, useSelector } from 'react-redux';
3-
import { launchContentScript } from '../slices/mainSlice';
3+
import { launchContentScript, setTab } from '../slices/mainSlice';
44
import { MainState, RootState, ErrorContainerProps } from '../FrontendTypes';
55
import { RefreshCw, Github, PlayCircle } from 'lucide-react';
66

@@ -10,11 +10,50 @@ function ErrorContainer(props: ErrorContainerProps): JSX.Element {
1010
(state: RootState) => state.main,
1111
);
1212

13+
// Add effect to initialize currentTab if not set
14+
useEffect(() => {
15+
const initializeCurrentTab = async () => {
16+
if (!currentTab) {
17+
try {
18+
// Query for the active tab
19+
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true });
20+
if (activeTab?.id) {
21+
dispatch(setTab(activeTab.id));
22+
}
23+
} catch (error) {
24+
console.error('Error getting active tab:', error);
25+
}
26+
}
27+
};
28+
29+
initializeCurrentTab();
30+
}, [currentTab, dispatch]);
31+
1332
// function that launches the main app and refreshes the page
1433
function launch(): void {
1534
// Add validation to ensure we have valid data
1635
if (!currentTab) {
17-
console.warn('No current tab available');
36+
console.warn('No current tab available - attempting to get active tab');
37+
// Try to get the active tab when launching
38+
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
39+
if (tabs[0]?.id) {
40+
const activeTabId = tabs[0].id;
41+
dispatch(setTab(activeTabId));
42+
// Create default payload and launch
43+
const defaultPayload = {
44+
status: {
45+
contentScriptLaunched: false,
46+
reactDevToolsInstalled: false,
47+
targetPageisaReactApp: false,
48+
},
49+
};
50+
dispatch(launchContentScript(defaultPayload));
51+
// Allow the dispatch to complete before refreshing
52+
setTimeout(() => {
53+
chrome.tabs.reload(activeTabId);
54+
}, 100);
55+
}
56+
});
1857
return;
1958
}
2059

0 commit comments

Comments
 (0)