From c43d46c7e88dcb382eecfcd2b14bfd3a58c75482 Mon Sep 17 00:00:00 2001 From: Gerlof van Ek Date: Tue, 15 Oct 2024 19:55:55 +0200 Subject: [PATCH] ui: Duplicate tooltip fix. --- basicswap/static/js/offerstable.js | 31 ++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/basicswap/static/js/offerstable.js b/basicswap/static/js/offerstable.js index d024ce5..1b0c262 100644 --- a/basicswap/static/js/offerstable.js +++ b/basicswap/static/js/offerstable.js @@ -796,8 +796,9 @@ function updateProfitLoss(row, fromCoin, toCoin, fromAmount, toAmount, isOwnOffe function createTableRow(offer, isSentOffers) { const row = document.createElement('tr'); + const uniqueId = `${offer.offer_id}_${offer.created_at}`; row.className = `opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600`; - row.setAttribute('data-offer-id', `${offer.offer_id}_${offer.created_at}`); + row.setAttribute('data-offer-id', uniqueId); const coinFromSymbol = coinNameToSymbol[offer.coin_from] || offer.coin_from.toLowerCase(); const coinToSymbol = coinNameToSymbol[offer.coin_to] || offer.coin_to.toLowerCase(); @@ -829,6 +830,8 @@ function createTableRow(offer, isSentOffers) { ${createTooltips(offer, isOwnOffer, coinFromDisplay, coinToDisplay, fromAmount, toAmount, postedTime, expiresIn, isActuallyExpired)} `; + updateTooltipTargets(row, uniqueId); + updateProfitLoss(row, coinFromDisplay, coinToDisplay, fromAmount, toAmount, isOwnOffer); return row; @@ -1286,8 +1289,10 @@ function createTooltips(offer, treatAsSentOffer, coinFrom, coinTo, fromAmount, t const percentageTooltipContent = createTooltipContent(treatAsSentOffer, coinFrom, coinTo, fromAmount, toAmount); + const uniqueId = `${offer.offer_id}_${offer.created_at}`; + return ` -