diff --git a/assets/companion.js b/assets/companion.js index 0132c98..e2122a2 100644 --- a/assets/companion.js +++ b/assets/companion.js @@ -115,13 +115,15 @@ function wireFileLinks() { if (!state.available) return; document.addEventListener('click', function (e) { - var item = e.target.closest && e.target.closest('.list-item'); - if (!item) return; - var anchor = e.target.closest('a'); + if (!e.target.closest) return; + // Match both listing styles: table rows expose the file link inside + // a .list-item row; thumbnail tiles are bare a.thumb-tile anchors. + var anchor = e.target.closest('.list-item a, a.thumb-tile'); if (!anchor) return; + var item = anchor.closest('.list-item'); // Only intercept the primary file link, and only for files (not folders). // Folders end with "/" — let the browser navigate normally. - var path = item.dataset.path || anchor.getAttribute('href'); + var path = (item && item.dataset.path) || anchor.getAttribute('href'); if (!path || path.endsWith('/')) return; // Allow modified clicks (open in new tab, etc.) to pass through. if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;