fix: settings search navigation and title-based search (#311)#385
fix: settings search navigation and title-based search (#311)#385superdav42 merged 1 commit intomainfrom
Conversation
- Replace item_add handler in selectizer.js to use selectize.options[value] instead of iterating a custom savedItems array with a hardcoded 'setting_id' comparison. The options store is always populated when an item is added, making navigation reliable regardless of AJAX timing. - Update search_wp_ultimo_setting() in class-ajax.php to search across setting_id, title, and desc fields (case-insensitive) instead of only setting_id. Users can now find settings by typing human-readable names like 'Company Name' rather than internal keys like 'company_name'. - Update selectizer.min.js with equivalent minified change.
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
Summary
Fixes the settings search box on the settings page — clicking a result item now navigates to the correct settings section.
Root Cause
Two bugs were present:
Bug 1 — Navigation (primary issue): The
item_addhandler inselectizer.jslooked up the selected item by iterating a customsavedItemsarray and comparingitem.setting_id === value. This approach was fragile:savedItemsis only populated in the AJAXsuccesscallback; if the item was added before the callback completed, the lookup returned nothingsetting_idwas hardcoded, making the handler non-genericBug 2 — Search scope:
search_wp_ultimo_setting()inclass-ajax.phponly searched thesetting_idfield (e.g.company_name). Users typing human-readable names like "Company Name" got no results.Changes
assets/js/selectizer.js+assets/js/selectizer.min.jsitem_addhandler to useselectize.options[value]— selectize's built-in options store, keyed byvalueField, which is always populated when an item is added. No custom array or hardcoded field name needed.inc/class-ajax.phparray_filterthat matches the search term againstsetting_id,title, anddescfields (case-insensitive). Results are sorted bytitle.Testing
Closes #311