Bugfix Issue 799 Quick Search Empty Table - sebiboga/testlink-upgraded GitHub Wiki
On the Quick Search screen (gui/templates/search/searchQuickView.html), clicking
Find intermittently rendered Search results (N matches) + a N matches footer, but the
results table body stayed EMPTY (no row). This was intermittent and happens "from time
to time".

The page loads jQuery + DataTables from external CDNs
(searchQuickView.html:115-117 — code.jquery.com, cdn.datatables.net). If the CDN is
slow/unavailable at the moment the user clicks Find, $.fn.DataTable is undefined.
renderResults() showed the count/wrapper first, then unconditionally called
$('#resTable').DataTable(...):
-
:215shows#matchCount("(1 matches)"); -
:226shows#resultsWrap; -
:242called$('#resTable').DataTable({...})with no guard.
When $.fn.DataTable is undefined, that call throws
(Uncaught TypeError: $(...).DataTable is not a function), aborting renderResults()
after the count/wrapper were already shown — leaving the count visible beside an empty
table body. The Find button also stayed disabled because the unhandled throw prevented
the $.getJSON(...).always(...) callback from re-enabling it.
renderResults() in searchQuickView.html:
- Renders a plain HTML
<tbody>first (via jQuery), so the matched rows always display regardless of DataTables availability. - Only then tries the DataTables enhancement, guarded by
typeof $.fn.DataTable === 'function'and wrapped intry/catch— if it fails, the plain table remains. - The up-front teardown now also nulls
resTbl(if (resTbl) { resTbl.destroy(); resTbl = null; ... }).
This keeps the count consistent with the rendered rows and lets the Find button re-enable
(.always() runs — no unhandled throw). No new user-facing strings were added, so no i18n
bundle changes were required.

-
Fallback scenario (
$.fn.DataTable = undefined, then Find): table renders the row (TLU-1 [v1] :: Login works, summary, version, edit/history buttons),1 matchesfooter, Find button re-enabled, no console JS error. - Normal scenario (DataTables present, then Find): enhanced DataTables table still renders with search box, pagination and sorting — no regression.
-
Event Viewer (
eventstable): no new Error/Warning (log_level 3/4) entries.
gui/templates/search/searchQuickView.html