ArchiveLabs / ArchiveLabs/openlibrary-components

fix: detach expanded search panel from header width constraints (min-width, viewport-anchored)

Open
#26 1 comment 0 reactions 0 assignees View on GitHub
bug enhancement
Dominant language
JavaScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Problem

The expanded `.panel` in `ol-search-bar` is currently bound to the width of its parent `.search-outer` via `position: absolute; left: 0; right: 0`. As the header shrinks at narrower viewports, the panel shrinks with it, causing two visible breakdowns:

- **Below ~945px** — facets in `.pf-bar` start to overflow the panel width
- **Below ~795px** — the barcode scanner icon overflows the search box and the layout visually breaks

This also means there's no guaranteed minimum usable width for the expanded experience on desktop/tablet.

## How GitHub and Hardcover.app solve this

Both apps **detach** the expanded search popup from the header's width. The visual trick:
- The popup is anchored to the **right edge** of the triggering search input (not the left)
- It has a fixed/minimum width independent of the header's shrinking width
- The search input *inside* the popup aligns vertically with the header input — so it appears to be the same element expanding in place
- GitHub: ~100% viewport width up to 1024px, then clamps to ~600px; right edge aligned with the search bar

## Proposed fix (surgical — no redesign)

Change `.panel` from parent-width-constrained absolute positioning to a **viewport-anchored fixed position** computed in JS when the panel opens:

1. On expand, read the bounding rect of the input element
2. Set `position: fixed; top: ; right: ` on the panel
3. Set `min-width: 600px` (or similar) so it never collapses below a usable width on desktop
4. On resize/scroll, recompute (or close the panel)
5. **Mobile full-screen overlay (<600px) stays completely intact** — no changes there
6. All internals (facets, suggestions, chips, autocomplete) are untouched

This is the same "detached popup" pattern used by GitHub and Hardcover.app.

## Acceptance criteria

- [ ] Expanded panel never goes below ~600px wide on desktop/tablet
- [ ] Facets never overflow at any desktop viewport width
- [ ] Right edge of expanded panel aligns with right edge of the search input
- [ ] No regression on mobile full-screen overlay (<600px)
- [ ] No regression on embedded (search-page) mode
- [ ] Panel repositions or closes on window resize

## Files likely touched

- `frontend/src/components/ol-search-bar.js` — panel positioning logic + CSS
- Tests: `ol-search-bar.mobile-overlay.test.js`, potentially new desktop breakpoint tests

Contributor guide

Open the contributing guide

Research direction

Start in frontend/src/components/ol-search-bar.js by reading the existing panel positioning and breakpoint logic. Run ol-search-bar.mobile-overlay.test.js, then add or run desktop breakpoint coverage for the listed acceptance criteria, including embedded mode and resize behavior. Done means the desktop/tablet panel stays usable and aligned while the mobile overlay remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.