66 PrimaryToggleButton ,
77} from "../../components"
88import styled from "styled-components"
9- import React , { useEffect , useState , useContext } from "react"
9+ import React , { useEffect , useState , useContext , useRef } from "react"
1010import { QuestContext } from "../../providers"
1111import { NewsItem } from "../../utils"
1212import { useDispatch , useSelector } from "react-redux"
@@ -93,8 +93,11 @@ const News = () => {
9393 // This boolean is to animate the bell icon and display a bullet indicator
9494 const [ hasUnreadNews , setHasUnreadNews ] = useState ( false )
9595 const activeSidebar = useSelector ( selectors . console . getActiveSidebar )
96+ const imageToZoom = useSelector ( selectors . console . getImageToZoom )
9697
97- let hoverTimeout : ReturnType < typeof setTimeout >
98+ const hoverTimeoutRef = useRef < ReturnType < typeof setTimeout > > ( )
99+ const imageToZoomRef = useRef ( imageToZoom )
100+ imageToZoomRef . current = imageToZoom
98101
99102 const getEnterpriseNews = async ( ) => {
100103 setIsLoading ( true )
@@ -248,7 +251,7 @@ const News = () => {
248251 ? {
249252 onMouseOver : ( ) => {
250253 if ( newsItem . thumbnail ) {
251- hoverTimeout = setTimeout ( ( ) => {
254+ hoverTimeoutRef . current = setTimeout ( ( ) => {
252255 if ( newsItem && newsItem . thumbnail ) {
253256 dispatch (
254257 actions . console . setImageToZoom ( {
@@ -268,12 +271,15 @@ const News = () => {
268271 }
269272 } ,
270273 onMouseOut : ( ) => {
271- clearTimeout ( hoverTimeout )
272- setTimeout ( ( ) => {
273- dispatch (
274- actions . console . setImageToZoom ( undefined ) ,
275- )
276- } , 250 )
274+ clearTimeout ( hoverTimeoutRef . current )
275+ // Only dismiss if zoom isn't visible (overlay intercepts mouse when visible)
276+ if ( ! imageToZoomRef . current ) {
277+ setTimeout ( ( ) => {
278+ dispatch (
279+ actions . console . setImageToZoom ( undefined ) ,
280+ )
281+ } , 250 )
282+ }
277283 } ,
278284 }
279285 : { } ) }
0 commit comments