Skip to content

Commit 3fba9ce

Browse files
committed
Fix tire search dropdown: no results + icon overlap
1. The tire data was passed to JS as flat numeric arrays via get_tires_as_array(), but tire-review.js accessed properties by name (t.brand, t.model, etc.), making every field undefined and the search haystack always empty. Now maps the flat rows into lightweight objects with named keys before localizing. 2. The search icon used a Font Awesome <i> class, but FA fonts may not load on the standalone page due to CSP restrictions. Replaced with an inline SVG so the icon always renders and never overlaps input text. https://claude.ai/code/session_01BAc9aiNw9dh4GeqEkpkxLK
1 parent cf42344 commit 3fba9ce

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

frontend/templates/tire-review.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@
705705

706706
<!-- Tire search -->
707707
<div class="rv-search-wrap">
708-
<i class="fa-solid fa-magnifying-glass rv-search-icon" aria-hidden="true"></i>
708+
<svg class="rv-search-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
709709
<input type="text" class="rv-search" id="rvTireSearch" placeholder="Search by brand, model, or size..." autocomplete="off" />
710710
<div class="rv-dropdown" id="rvDropdown"></div>
711711
</div>

includes/class-rtg-tire-review.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,23 @@ public function load_template() {
8484
$tire_guide_url = get_permalink( $guide_pages[0] );
8585
}
8686

87+
// Build lightweight tire list with named keys for the review page JS.
88+
$raw_tires = RTG_Database::get_tires_as_array();
89+
$review_tires = array();
90+
foreach ( $raw_tires as $row ) {
91+
$review_tires[] = array(
92+
'tire_id' => $row[0],
93+
'brand' => $row[3],
94+
'model' => $row[4],
95+
'size' => $row[1],
96+
'category' => $row[5],
97+
'image' => $row[19],
98+
);
99+
}
100+
87101
// Localize tire data and review config for the review page.
88102
wp_localize_script( 'rtg-tire-review', 'rtgTireReview', array(
89-
'tires' => RTG_Database::get_tires_as_array(),
103+
'tires' => $review_tires,
90104
'ajaxurl' => admin_url( 'admin-ajax.php' ),
91105
'nonce' => wp_create_nonce( 'tire_rating_nonce' ),
92106
'is_logged_in' => is_user_logged_in(),

0 commit comments

Comments
 (0)