Skip to content

fix: settings search navigation and title-based search (#311)#385

Merged
superdav42 merged 1 commit intomainfrom
bugfix/311-settings-search-navigation
Mar 24, 2026
Merged

fix: settings search navigation and title-based search (#311)#385
superdav42 merged 1 commit intomainfrom
bugfix/311-settings-search-navigation

Conversation

@superdav42
Copy link
Copy Markdown
Collaborator

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_add handler in selectizer.js looked up the selected item by iterating a custom savedItems array and comparing item.setting_id === value. This approach was fragile:

  • savedItems is only populated in the AJAX success callback; if the item was added before the callback completed, the lookup returned nothing
  • The field name setting_id was hardcoded, making the handler non-generic

Bug 2 — Search scope: search_wp_ultimo_setting() in class-ajax.php only searched the setting_id field (e.g. company_name). Users typing human-readable names like "Company Name" got no results.

Changes

assets/js/selectizer.js + assets/js/selectizer.min.js

  • Replace the item_add handler to use selectize.options[value] — selectize's built-in options store, keyed by valueField, which is always populated when an item is added. No custom array or hardcoded field name needed.

inc/class-ajax.php

  • Replace the Arrch-based single-field search with a native PHP array_filter that matches the search term against setting_id, title, and desc fields (case-insensitive). Results are sorted by title.

Testing

  1. Go to Network Admin → WP Ultimo → Settings
  2. Type "company" in the search box — results should appear including "Company Name", "Company Address", etc.
  3. Click any result — the page should navigate to the correct settings section with the field highlighted via the URL hash

Closes #311

- 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.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 24, 2026

Warning

Rate limit exceeded

@superdav42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 51 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 51d45ea2-6ca8-448a-9ab7-2e49a7d120dc

📥 Commits

Reviewing files that changed from the base of the PR and between b8df0b8 and f67cde8.

⛔ Files ignored due to path filters (1)
  • assets/js/selectizer.min.js is excluded by !**/*.min.js
📒 Files selected for processing (2)
  • assets/js/selectizer.js
  • inc/class-ajax.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/311-settings-search-navigation

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

🔨 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!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@superdav42 superdav42 merged commit 0b37054 into main Mar 24, 2026
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The search box on setting page is broken

1 participant