Files
gh-christianlouis-docuelevate/app/views/search.py
copilot-swe-agent[bot] 09a6337c6f fix(ui): prevent search input from clearing on each keystroke and add dedicated /search page
The debounceSearch() function in files.html called clearFullTextSearch()
when the query was shorter than 2 characters. Since clearFullTextSearch()
sets input.value = '', every single keystroke was immediately erased —
users could paste text but not type.

Fix: debounceSearch now only hides the results panel for short queries
without touching the input value.

Also adds a dedicated /search page with Google-style results showing
content previews (document title, filename, type badges, tag badges,
sender, and OCR text snippets with highlighted matches).

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-26 09:18:28 +00:00

39 lines
986 B
Python

"""
Search view for dedicated full-text document search page.
Provides a Google-style search experience with content previews,
powered by Meilisearch via the existing ``/api/search`` backend.
"""
import logging
from typing import Optional
from fastapi import Query, Request
from app.views.base import APIRouter, require_login, templates
logger = logging.getLogger(__name__)
router = APIRouter()
@router.get("/search")
@require_login
def search_page(
request: Request,
q: Optional[str] = Query(None, max_length=512, description="Full-text search query"),
):
"""Render the dedicated search page.
The page loads with an empty search box (or pre-filled when *q* is given).
Actual searching is performed client-side via ``fetch('/api/search')`` so
that results stream in without a full page reload.
"""
return templates.TemplateResponse(
"search.html",
{
"request": request,
"query": q or "",
},
)