Skip to content

Commit e39a4e3

Browse files
committed
(add) Finished proper dispatch which makes the onHover feature compatible for both Recoil and non-recoil applications
Co-authored-By: Sanjay Lavingia <[email protected]>
1 parent d95398f commit e39a4e3

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/app/components/ComponentMap.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ export default function ComponentMap({
151151
node.data.isExpanded = !node.data.isExpanded;
152152
forceUpdate();
153153
}}
154+
154155
onMouseEnter={()=> {
155-
156-
if(node.data.recoilDomNode){
156+
if(Object.keys(node.data.recoilDomNode).length > 0){
157157
dispatch(onHover(node.data.recoilDomNode[node.data.name]))
158158
} else {
159-
dispatch(onHover(rtid))
159+
dispatch(onHover(node.data.rtid))
160160
}
161161

162162
}

src/backend/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ window.addEventListener('message', ({ data: { action, payload } }: MsgData) => {
5959
mode.paused = payload;
6060
break;
6161
case 'onHover':
62-
62+
console.log(payload);
63+
6364
if(Array.isArray(payload)){
6465
for (let i=0; i<payload.length;i++){
6566
let element = document.getElementById(payload[i])
@@ -70,6 +71,14 @@ window.addEventListener('message', ({ data: { action, payload } }: MsgData) => {
7071
}, 500)
7172
}
7273
}
74+
} else {
75+
let element = document.getElementById(payload)
76+
if (element !== null) {
77+
element.style.backgroundColor = '#C0D9D9';
78+
setTimeout( () => {
79+
element.style.backgroundColor = "";
80+
}, 500)
81+
}
7382
}
7483

7584
// if (payload !== null) {

0 commit comments

Comments
 (0)