Skip to content

Correct what the activeElement branches actually cover - #609

Merged
aaronbrethorst merged 1 commit into
OneBusAway:developfrom
omlahore:fix/favorites-focus-comment
Sep 21, 2026
Merged

aaronbrethorst merged 1 commit into
OneBusAway:developfrom
omlahore:fix/favorites-focus-comment

Conversation

@omlahore

@omlahore omlahore commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Folding in the correction from the review on #605, comment only, no behaviour change.

The claim that a map click leaves activeElement at <body> is wrong on the default provider. I checked each step rather than taking it on faith:

  • .env.example:31 sets PUBLIC_OBA_MAP_PROVIDER="osm"
  • OpenStreetMapProvider.svelte.js:98 builds the map as this.L.map(element, { zoomControl: false }), so keyboard stays at Leaflet's default of true
  • leaflet/src/map/handler/Map.Keyboard.js:42-46 does if (container.tabIndex <= 0) { container.tabIndex = '0'; } and binds mousedown to _onMouseDown, which focuses the container
  • MapView.svelte:406 is <div id="map" bind:this={mapElement}></div>, no tabindex of its own

So an OSM map click puts focus on the map container, a focusable element outside rootEl, and restoreFocus is false there. That is the behaviour you want, focus follows what the user clicked, and the container is arrow-key pannable so nothing is stranded. Only the reason given was wrong.

The comment now describes the <body> branch as what it actually covers, non-focusable chrome such as the mobile in-flow area, and keeps the rootEl branch separate since that one is about focus stranded inside the closing panel.

FavoritesFloatingControl.test.js still passes, 9 of 9, and prettier is clean.

Summary by CodeRabbit

  • Documentation
    • Clarified inline comments describing focus restoration behavior when closing the favorites panel, including interactions with the map and non-focusable interface areas.

The comment said a map click leaves activeElement at <body>. It does not on
the default OSM provider: Leaflet's keyboard handler sets tabIndex on the map
container and focuses it on mousedown, and OpenStreetMapProvider.initMap does
not pass keyboard: false, so the click lands focus on the container.

The behaviour is right either way, focus follows the thing the user clicked.
Only the stated reason was wrong, so the <body> branch is described as what it
is: non-focusable chrome, not the map.
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: a865c67d-6a7f-4c40-af95-40d1add69e7f

📥 Commits

Reviewing files that changed from the base of the PR and between a97d145 and cd0866b.

📒 Files selected for processing (1)
  • src/components/favorites/FavoritesFloatingControl.svelte

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change rewrites comments in handleWindowClick to clarify existing focus restoration behavior. No code logic, control flow, or error handling changed.

Changes

Focus restoration

Layer / File(s) Summary
Focus restoration branch comments
src/components/favorites/FavoritesFloatingControl.svelte
Comments now explain the <body> branch, Leaflet map focus behavior, and the separate rootEl branch.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to cd086

This update clarifies focus-restoration documentation without changing application behavior, so it presents no current merge-readiness risk.

Suggested reviewers: tarunsinghofficial

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: correcting comments about which activeElement branches are handled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage is 93.459%omlahore:fix/favorites-focus-comment into OneBusAway:develop. No base build found for OneBusAway:develop.

@aaronbrethorst

Copy link
Copy Markdown
Member

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@aaronbrethorst aaronbrethorst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment-only, and correct. I checked the claim rather than taking it on faith: OpenStreetMapProvider.svelte.js:98 builds the map as this.L.map(element, { zoomControl: false }) with no keyboard: false, so Leaflet's default keyboard handler does set tabIndex on the container and take focus on mousedown. The old comment's claim that a map click leaves activeElement at <body> was wrong on the default provider.

Splitting the <body> and rootEl branches apart also makes the actual reasoning legible — they cover genuinely different cases and the old single sentence blurred them together.

Thanks for folding the correction back in as its own change rather than leaving it buried in the #605 thread.

@aaronbrethorst
aaronbrethorst merged commit fa35c8e into OneBusAway:develop Sep 21, 2026
6 checks passed
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.

3 participants