Skip to content

Commit 4af16ca

Browse files
committed
tool tip with ignored state and properties
1 parent e044280 commit 4af16ca

File tree

3 files changed

+60
-34
lines changed

3 files changed

+60
-34
lines changed

src/app/components/StateRoute/AxMap/Ax.tsx

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import { Group } from '@visx/group';
33
import { hierarchy, Tree } from '@visx/hierarchy';
44
import { LinearGradient } from '@visx/gradient';
55
import { pointRadial } from 'd3-shape';
6-
import { useTooltipInPortal } from '@visx/tooltip';
76
import LinkControls from './axLinkControls';
87
import getLinkComponent from './getAxLinkComponents';
98
import { useTooltip, useTooltipInPortal, defaultStyles } from '@visx/tooltip';
10-
import ToolTipDataDisplay from '../ComponentMap/ToolTipDataDisplay';
9+
import ToolTipDataDisplay from './ToolTipDataDisplay';
1110
import { ToolTipStyles } from '../../../FrontendTypes';
1211
import { localPoint } from '@visx/event';
1312

@@ -202,11 +201,11 @@ export default function AxTree(props) {
202201
pointerEvents: 'all !important',
203202
};
204203

205-
const formatRenderTime = (time: number): string => {
206-
if (!time) return 'No time information';
207-
const renderTime = time.toFixed(3);
208-
return `${renderTime} ms `;
209-
};
204+
// const formatRenderTime = (time: number): string => {
205+
// if (!time) return 'No time information';
206+
// const renderTime = time.toFixed(3);
207+
// return `${renderTime} ms `;
208+
// };
210209

211210

212211

@@ -315,14 +314,6 @@ export default function AxTree(props) {
315314
populateNodeAxArr(rootAxNode);
316315
console.log('nodeAxArr: ', nodeAxArr);
317316

318-
const {
319-
containerRef // Access to the container's bounding box. This will be empty on first render.
320-
} = useTooltipInPortal({
321-
// Visx hook
322-
detectBounds: true, // use TooltipWithBounds
323-
scroll: true, // when tooltip containers are scrolled, this will correctly update the Tooltip position
324-
});
325-
326317
return totalWidth < 10 ? null : (
327318
<div>
328319
<LinkControls
@@ -601,13 +592,8 @@ export default function AxTree(props) {
601592
<strong>{JSON.stringify(tooltipData['name'].value)}</strong>
602593
</div>
603594
<div>
604-
<ToolTipDataDisplay containerName='Props' dataObj={tooltipData} />
605-
<ToolTipDataDisplay
606-
containerName='State'
607-
dataObj={
608-
tooltipData
609-
}
610-
/>
595+
<ToolTipDataDisplay containerName='Ax State' dataObj={tooltipData} />
596+
{/* <ToolTipDataDisplay containerName='State'dataObj={tooltipData}/> */}
611597
</div>
612598
</div>
613599
</TooltipInPortal>

src/app/components/StateRoute/AxMap/ToolTipDataDisplay.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,25 @@ const ToolTipDataDisplay = ({ containerName, dataObj }) => {
4040
JSON objects can't contain circular ref's, so the backend filters out problematic values by stringifying the values of object properties and ignoring any values that fail the conversion due to a circular ref. The following logic converts these values back to JS so they display clearly and are collapsible.
4141
*/
4242
const data = {};
43+
//ignored false vs true
44+
//ignored reasons here
45+
//&& key = name? / order?
4346
for (const key in dataObj) {
44-
if (typeof dataObj[key] === 'string') {
45-
try {
46-
data[key] = JSON.parse(dataObj[key]);
47-
} catch {
47+
console.log('keys in dataObj in tooltiptotalDisplay: ', key);
48+
if(key === 'properties' || key === 'ignored' || key === 'ignoredReasons'){// loop through properties, adding them to the data object
49+
50+
if (typeof dataObj[key] === 'string') {
51+
//if 'key' is ignored, put the ignored key and its value on the data object
52+
//if ignoredReasons has length it should loop through adding the reasons names to the data object
53+
//actually might only need to give it the properties and ignored and ignored reasons and it'll take care of the rest
54+
try {
55+
data[key] = JSON.parse(dataObj[key]);
56+
} catch {
57+
data[key] = dataObj[key];
58+
}
59+
} else {
4860
data[key] = dataObj[key];
4961
}
50-
} else {
51-
data[key] = dataObj[key];
5262
}
5363
}
5464
/*

src/extension/background.js

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ const metrics = {};
1717
// function pruning the chrome ax tree and pulling the relevant properties
1818
const pruneAxTree = (axTree) => {
1919
const axArr = [];
20+
let orderCounter = 0
21+
2022
for (const node of axTree) {
23+
2124
let {
2225
backendDOMNodeId,
2326
childIds,
@@ -30,34 +33,61 @@ const pruneAxTree = (axTree) => {
3033
role
3134
} = node;
3235

36+
// let order;
37+
3338
if(!name){
3439
if(ignored){
35-
name = {value: `ignored node: ${ignoredReasons[0].name}`};
40+
name = {value: 'ignored node'};
3641
}
3742
else{
38-
name = {value: 'visible node with no name'};
43+
name = {value: 'no name'};
3944
}
4045
}
4146
if(!name.value){
42-
name.value = 'visible node with no name';
47+
name.value = 'no name';
4348
}
44-
49+
//if the node is ignored, it should be given an order number as it won't be read at all
50+
// if(ignored){
51+
// order = null;
52+
// }
53+
// else{
54+
// order = orderCounter++;
55+
// }
4556
if (role.type === 'role') {
4657
const axNode = {
4758
backendDOMNodeId: backendDOMNodeId,
4859
childIds: childIds,
4960
ignored: ignored,
61+
ignoredReasons: ignoredReasons,
5062
name: name,
5163
nodeId: nodeId,
5264
ignoredReasons: ignoredReasons,
5365
parentId: parentId,
5466
properties: properties,
67+
// order: order,
5568
};
56-
5769
axArr.push(axNode);
5870
}
5971
}
60-
console.log('axArr: ', axArr);
72+
73+
// Sort nodes by backendDOMNodeId in ascending order
74+
//try with deep copy
75+
// //aria properties
76+
// console.log('axArr before : ', axArr);
77+
// axArr.sort((a, b) => b.backendDOMNodeId - a.backendDOMNodeId);
78+
79+
// Assign order based on sorted position
80+
for (const axNode of axArr) {
81+
// console.log('current axnode order number: ', axNode.order)
82+
// console.log('this iterations node', axNode);
83+
if (!axNode.ignored) { // Assuming you only want to assign order to non-ignored nodes
84+
axNode.order = orderCounter++;
85+
} else {
86+
axNode.order = null; // Or keep it undefined, based on your requirement
87+
}
88+
// console.log('current axnode order number: ', axNode.order)
89+
}
90+
// console.log('axArr after: ', axArr);
6191
return axArr;
6292
};
6393

0 commit comments

Comments
 (0)