Skip to content

Commit

Permalink
Merge pull request Expensify#30462 from kacper-mikolajczak/fix/30278/…
Browse files Browse the repository at this point in the history
…hoverable-crashes-on-devtools

[Fix][Web] App crash on device toolbar toggle
  • Loading branch information
youssef-lr authored Oct 28, 2023
2 parents a59d56f + d7d19c1 commit 8da0ab1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/components/Hoverable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,21 @@ const Hoverable = React.forwardRef(({disabled, onHoverIn, onHoverOut, onMouseEnt
[child.props],
);

// We need to access the ref of a children from both parent and current component
// So we pass it to current ref and assign it once again to the child ref prop
const hijackRef = (el) => {
ref.current = el;
assignRef(child.ref, el);
};

if (!DeviceCapabilities.hasHoverSupport()) {
return child;
return React.cloneElement(child, {
ref: hijackRef,
});
}

return React.cloneElement(child, {
ref: (el) => {
ref.current = el;
assignRef(child.ref, el);
},
ref: hijackRef,
onMouseEnter: enableHoveredOnMouseEnter,
onMouseLeave: disableHoveredOnMouseLeave,
onBlur: disableHoveredOnBlur,
Expand Down

0 comments on commit 8da0ab1

Please sign in to comment.