wedocs-plugin icon indicating copy to clipboard operation
wedocs-plugin copied to clipboard

Feature/search form modal integration

Open arifulhoque7 opened this issue 2 months ago • 1 comments

📌 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:

  1. Navigate to the WeDocs documentation home page.
  2. Type in the search field and verify that results appear dynamically without page reload.
  3. Confirm that search results update with each keystroke.
  4. Test responsiveness on mobile, tablet, and desktop.
  5. Disable JavaScript and verify that query-based search still works as a fallback.
  6. 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.

arifulhoque7 avatar Sep 25 '25 10:09 arifulhoque7

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 logic
assets/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 behavior
includes/Frontend.php
Sets isSingleDoc to true unconditionally in Frontend::register_scripts; no signature changes.
Search form template tweaks
templates/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.

❤️ Share

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

coderabbitai[bot] avatar Sep 25 '25 10:09 coderabbitai[bot]