wedocs-plugin
wedocs-plugin copied to clipboard
Feature/search form modal integration
📌 PR Description Close issue
Feature: Convert Query-based Search to AJAX Search – WeDocs Docs Home
Summary: This PR replaces the traditional query-based search with an AJAX-powered live search in the WeDocs documentation home page. The new search implementation provides a faster and smoother user experience by fetching results dynamically without a full page reload.
Changes Implemented:
- Replaced query parameter–based search with AJAX calls.
- Implemented live search dropdown that updates results as the user types.
- Enhanced user experience with instant feedback and loading states.
- Optimized search query for performance and reduced unnecessary database calls.
- Added fallback for non-JS environments (graceful degradation).
- Applied styling adjustments for the new search results container.
- Ensured accessibility (keyboard navigation, ARIA roles for results).
Testing Steps:
- Navigate to the WeDocs documentation home page.
- Type in the search field and verify that results appear dynamically without page reload.
- Confirm that search results update with each keystroke.
- Test responsiveness on mobile, tablet, and desktop.
- Disable JavaScript and verify that query-based search still works as a fallback.
- Validate that existing documentation browsing functionality is unaffected.
Summary by CodeRabbit
- New Features
- Always enable the single-document search modal for easier in-page searching.
- Bug Fixes
- Prevent errors and broken states with safer handling when elements are missing.
- Only mount the search modal when available, avoiding unintended DOM changes.
- More reliable navigation highlighting and modal open/close behavior.
- Style
- Refined positioning and padding for the search input and button.
- UI Changes
- Search input is now read-only with a dedicated button to trigger the modal.
Walkthrough
Enables and guards the single-document search modal across the app, adds null-safe checks and error handling in frontend JS, adjusts PHP to always set isSingleDoc true, and updates the search form template with styling, a readonly input, and a button-based trigger.
Changes
| Cohort / File(s) | Summary of changes |
|---|---|
Frontend JS safety and modal logicassets/js/frontend.js |
Adds null checks, optional chaining, and try/catch around search hit processing; removes early return to always init single-doc search; mounts modal only if weDocs_Vars.searchModal exists; guards show/close operations; verifies ancestor element before toggling classes. |
Script localization behaviorincludes/Frontend.php |
Sets isSingleDoc to true unconditionally in Frontend::register_scripts; no signature changes. |
Search form template tweakstemplates/doc-search-form.php |
Adds inline styles; appends wedocs-single-search-input class; sets input readonly; changes submit input to a button element. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
A bunny taps keys with a gentle thrum,
Nulls are tamed, the errors go numb.
A modal hops in when the flags align,
The search field shimmers—readonly fine.
With button clicks and softened light,
I nose-twitch, ship it—everything’s right. 🐇✨
Pre-merge checks and finishing touches
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title Check | ✅ Passed | The title succinctly describes the central change—integration of the search form modal—clearly reflecting the main purpose of this pull request without extraneous details. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✨ Finishing touches
- [ ] 📝 Generate Docstrings
🧪 Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
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 @coderabbitai help to get the list of available commands and usage tips.