From 826688a3f6bcbc6ef6f36e54639623b6fcfef95c Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Mon, 9 Mar 2026 10:10:32 +0100 Subject: [PATCH] fix: prevent BuyBox badge visual duplication - Wrap component with memo() to prevent unnecessary re-renders - Restructure DOM hierarchy to avoid nested inline-flex containers - Center hover popup with left-1/2 -translate-x-1/2 - Add pointer-events-none to popup to prevent hover flickering - Improve popup spacing and sizing Co-authored-by: Qwen-Coder --- components/BuyBoxWarningBadge.tsx | 72 +++++++++++++++---------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/components/BuyBoxWarningBadge.tsx b/components/BuyBoxWarningBadge.tsx index 0eeb21d..2b84b5e 100644 --- a/components/BuyBoxWarningBadge.tsx +++ b/components/BuyBoxWarningBadge.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, memo } from 'react'; interface BuyBoxWarningBadgeProps { asin: string; @@ -13,7 +13,7 @@ const COUNTRY_FLAGS: Record = { ES: '🇪🇸', }; -export const BuyBoxWarningBadge: React.FC = ({ asin, buyBoxLostMap }) => { +export const BuyBoxWarningBadge: React.FC = memo(({ asin, buyBoxLostMap }) => { const [isHovered, setIsHovered] = useState(false); if (!buyBoxLostMap || !asin) return null; @@ -27,45 +27,45 @@ export const BuyBoxWarningBadge: React.FC = ({ asin, bu if (!data || data.countries.length === 0) return null; return ( -
setIsHovered(true)} - onMouseLeave={() => setIsHovered(false)} - > -
+
+
setIsHovered(true)} + onMouseLeave={() => setIsHovered(false)} + > ⚠️ BB Lost {data.countries.slice(0, 3).join(', ')}{data.countries.length > 3 ? '...' : ''} -
- {/* Hover Popup */} - {isHovered && ( -
-
- - ⚠️ Buy Box Lost Reason - -
-
- {data.countries.map(country => ( -
- {COUNTRY_FLAGS[country] || '🏳️'} -
- - {country} - - - {data.reasons[country] || 'Unknown'} - + {/* Hover Popup */} + {isHovered && ( +
+
+ + ⚠️ Buy Box Lost Reason + +
+
+ {data.countries.map(country => ( +
+ {COUNTRY_FLAGS[country] || '🏳️'} +
+ + {country} + + + {data.reasons[country] || 'Unknown'} + +
-
- ))} + ))} +
-
- )} + )} +
); -}; +});