Skip to content

Add single-character author search frontend validation#11854

Open
agabedc wants to merge 6 commits intointernetarchive:masterfrom
agabedc:9290/fix/single-character-author-searches
Open

Add single-character author search frontend validation#11854
agabedc wants to merge 6 commits intointernetarchive:masterfrom
agabedc:9290/fix/single-character-author-searches

Conversation

@agabedc
Copy link

@agabedc agabedc commented Feb 11, 2026

Addresses some of the acceptance criteria for ticket #9290

Handles frontend validation for searching authors from both the https://openlibrary.org/search/authors search page and navbar search, restricting searches of only 1 character when "Author" is selected.

Technical

It should be noted that this only addresses some of the acceptance criteria for ticket #9290 -- not all of it. Also, our solution uses vanilla JavaScript to modify HTML attributes on the client side as opposed to if-statements in the Web.py templating.

We are submitting what we have so far so that a stakeholder can review our code before moving ahead with backend validation and author additions.

Testing

  1. Search by "Author" in the navbar.
  2. Search by "Author" on the search page.
  3. Observe HTML error message.

Screenshot

image image

Stakeholders

@cdrini, @mekarpeles

Copilot AI review requested due to automatic review settings February 11, 2026 21:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds frontend validation to prevent single-character author searches, addressing part of issue #9290. The implementation uses vanilla JavaScript to dynamically set HTML5 validation attributes (minlength, pattern) on search inputs when the "Author" search category is selected. The validation is applied in two key locations: the dedicated author search page and the navbar search bar.

Changes:

  • Added client-side validation requiring at least 2 characters for author searches
  • Modified searchbox template to accept an optional category parameter
  • Implemented inline JavaScript validation scripts in both navbar and author search page

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.

File Description
openlibrary/templates/search/searchbox.html Added category parameter to template definition and inline script that applies validation attributes when category is 'authors'
openlibrary/templates/search/authors.html Updated to pass category='authors' when rendering searchbox template
openlibrary/templates/lib/nav_head.html Added inline script to dynamically apply/remove validation based on selected search facet (author vs. other types)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

agabedc and others added 3 commits February 18, 2026 20:11
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

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.

2 participants

Comments