Explorar o código

fix: Resolve US-08 bug where Details panel would not fetch nutritional data

FerRo988 hai 2 semanas
pai
achega
60a30f124e
Modificáronse 1 ficheiros con 3 adicións e 4 borrados
  1. 3 4
      static/script.js

+ 3 - 4
static/script.js

@@ -482,9 +482,7 @@ document.addEventListener('DOMContentLoaded', () => {
                         <div class="food-item-footer">
                             <button class="details-btn" data-id="${item.id}">📊 Details</button>
                         </div>
-                        <div class="details-panel" id="details-${item.id}">
-                            <!-- Populated on demand -->
-                        </div>
+                        <div class="details-panel" id="details-${item.id}"></div>
                     `;
                     
                     // Click on the header/name area auto-fills the chat
@@ -527,7 +525,8 @@ document.addEventListener('DOMContentLoaded', () => {
         }
 
         // If not loaded yet, fetch from API
-        if (panel.innerHTML.trim() === '') {
+        if (panel.innerHTML.trim() === '' || panel.innerHTML.includes('Loading')) {
+            console.log(`[UI] Fetching details for food ${foodId}...`);
             panel.innerHTML = '<div class="search-loading">Loading details...</div>';
             panel.classList.add('expanded'); // Show loading state