Skip to content

fix(google_flights): keep swap button on origin/destination seam - #118

Open
Lxr-max wants to merge 1 commit into
aiming-lab:mainfrom
Lxr-max:cursor/fix-google-flights-swap-b2b9
Open

Lxr-max wants to merge 1 commit into
aiming-lab:mainfrom
Lxr-max:cursor/fix-google-flights-swap-b2b9

Conversation

@Lxr-max

@Lxr-max Lxr-max commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Summary

On the Google Flights homepage the swap button was absolutely positioned against the whole search row (origin + destination + dates). That put it in the middle of the destination field, and filling origin made the misalignment worse.

This groups origin and destination into a dedicated .search-route-fields container and positions .search-swap relative to that group so it stays on the seam. Date fields stay in a sibling .search-dates group. On mobile (stacked fields) the swap button remains hidden.

Fixes #20.

Changes

  • Wrap origin, swap, and destination in .search-route-fields (sites/google_flights/templates/index.html)
  • Position the swap button on that group's midpoint, not the full row (sites/google_flights/static/css/main.css)
  • Keep equal origin/destination columns via CSS grid so filled origin text cannot shift the seam
  • Leave hotels/vacation-rentals row layout intact (still uses .search-field { flex: 1 } outside the route group)
  • Add a static layout regression in sites/google_flights/tests/test_search_swap_layout.py

Checklist

  • Origin/destination grouped separately from date fields
  • Swap button centered on the origin/destination seam (left: 50% of .search-route-fields)
  • Swap hidden at max-width: 768px
  • Static regression test for the HTML/CSS contract
  • Visual verification (desktop filled origin + mobile)

Verification

python3 -m py_compile sites/google_flights/app.py
python3 sites/google_flights/tests/test_search_swap_layout.py

Both passed. Chrome headless layout check of the homepage search widget with origin filled (New York (JFK)):

Viewport Swap vs origin/destination seam Overlaps dates Swap visible
1280px before seamDelta: 190, insideDestination: true no yes (wrong place)
1280px after seamDelta: 0 no yes, on the seam
375px after swapDisplay: none no hidden

Before (swap sits inside destination):

Before: swap button inside destination field

After, desktop (swap on the origin/destination seam, dates clear):

After: swap button on origin/destination seam

After, mobile (fields stacked, swap hidden):

After: mobile stacked fields hide the swap button

The live Flask homepage was not exercised in Docker here because sites/google_flights/instance_seed/ is HF-managed and not present in this checkout. The screenshots use the committed homepage search markup plus static/css/main.css.

Group origin and destination in a dedicated route-field container and
position the swap control on that group's midpoint so it no longer sits
inside the destination input when origin has a value. Hide the button
when fields stack on mobile.

Co-authored-by: Lxr-max <Lxr-max@users.noreply.github.com>
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.

Google Flights swap button shifts into destination field

1 participant