Skip to content

feat: show error message in autocomplete panel on search API failure#41

Merged
mekarpeles merged 2 commits intomainfrom
feat/autocomplete-error-state
Apr 27, 2026
Merged

feat: show error message in autocomplete panel on search API failure#41
mekarpeles merged 2 commits intomainfrom
feat/autocomplete-error-state

Conversation

@mekarpeles
Copy link
Copy Markdown
Member

Closes #36

Problem

A network failure or 500 during _fetchAutocomplete previously cleared _suggestions and silently rendered nothing. The open panel looked identical to "type more to search" — no way for users to know search was broken.

Changes

  • _acError: { state: true } added to properties, initialised false
  • _fetchAutocomplete resets _acError = false at the start of each attempt; sets _acError = true on any non-abort exception
  • _renderResults checks _acError before the hint/results branches → returns a role="alert" error div
  • .ac-error CSS: muted red text on a light red background, same padding as .ac-hint-msg

Done checklist

  • _acError declared as reactive state
  • _acError = false reset at start of every fetch
  • _acError = true set on non-abort errors
  • _renderResults renders .ac-error with role="alert" when true
  • .ac-error CSS rule in component styles
  • 6 static-analysis tests verify the full contract
  • 173 tests pass, lint clean

closes #36

Previously a non-abort fetch error in _fetchAutocomplete cleared
_suggestions and silently rendered nothing — indistinguishable from "no
results yet." Users had no way to know search was broken.

Adds _acError reactive state (bool). _fetchAutocomplete resets it to
false on each attempt and sets it to true on any non-abort exception.
_renderResults now checks _acError before the hint/results branches and
returns a .ac-error div with role="alert". A muted-red CSS rule gives it
visual weight without being alarming.

Six static-analysis tests in ol-search-bar.panel-overlay.test.js verify
the full contract: state declaration, initialization, set/reset in fetch,
render branch, and CSS rule.
Copilot AI review requested due to automatic review settings April 26, 2026 22:52
Copy link
Copy Markdown
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

Adds an explicit autocomplete error state to ol-search-bar so users see a visible message in the open panel when the search API fails, instead of an indistinguishable empty state.

Changes:

  • Introduces reactive _acError state, set/reset in _fetchAutocomplete() based on non-abort failures.
  • Renders an .ac-error alert message in the autocomplete panel when _acError is true, and adds corresponding CSS styling.
  • Adds static contract tests to assert _acError state, render branch, and CSS rule presence.

Reviewed changes

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

File Description
frontend/src/components/ol-search-bar.js Adds _acError state, error UI branch in _renderResults, and .ac-error styling.
frontend/src/components/ol-search-bar.panel-overlay.test.js Adds static-analysis contract tests validating the _acError implementation.

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

Comment thread frontend/src/components/ol-search-bar.js
Comment thread frontend/src/components/ol-search-bar.panel-overlay.test.js
- _acError now cleared in _onInput early-return path (q < 2 chars) and
  in _clearInput() so a stale error message does not persist after the
  user clears the input or drops below the minimum query length
- Test slice anchored on 'async _fetchAutocomplete()' (method signature)
  instead of '_fetchAutocomplete' (which matched the setTimeout call site)
- Two new tests verify _acError is cleared in both reset paths
@mekarpeles mekarpeles merged commit b16a4e7 into main Apr 27, 2026
2 checks passed
@mekarpeles mekarpeles deleted the feat/autocomplete-error-state branch April 27, 2026 00:08
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.

feat: show error message in autocomplete panel on search API failure

2 participants