We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b8f0630 commit a9cc01cCopy full SHA for a9cc01c
1 file changed
src/lib/ui/ComparisonDisplay.svelte
@@ -197,13 +197,18 @@
197
const bestValue = getBestValue(products, nutrientKey);
198
const worstValue = getWorstValue(products, nutrientKey);
199
200
+ // Count how many products have this nutrient to avoid highlighting "best" when only one is compared
201
+ const comparableCount = products
202
+ .map((p) => getNutrientValue(p, nutrientKey))
203
+ .filter((v): v is number => v !== null).length;
204
+
205
return {
206
value,
207
formatted,
208
diff,
209
diffFormatted,
- isBest: bestValue === value,
- isWorst: value === worstValue && products.length > 1
210
+ isBest: comparableCount > 1 && bestValue === value,
211
+ isWorst: comparableCount > 1 && worstValue === value
212
};
213
}
214
0 commit comments