Skip to content

馃 fix: focus main region after sidebar collapse - #3995

Closed
tracyjohnsonux wants to merge 1 commit into
mainfrom
fix/sidebar-collapse-focus
Closed

馃 fix: focus main region after sidebar collapse#3995
tracyjohnsonux wants to merge 1 commit into
mainfrom
fix/sidebar-collapse-focus

Conversation

@tracyjohnsonux

Copy link
Copy Markdown

Summary

Focus the active route's main region after a sidebar collapse so keyboard input is not left on the collapsed rail button. Workspace, project creation, and scratch routes focus their chat composer; settings and analytics focus their main content region.

Background

When both side panels are collapsed on desktop, the last clicked collapse button can keep focus. Pressing Enter then re-activates the rail button instead of sending the chat message. This change routes sidebar collapse through a route-owned main-region focus event rather than hard-coding every collapse to the chat input.

Implementation

  • Add a typed FOCUS_MAIN_REGION custom event and a useFocusMainRegion helper.
  • Dispatch the focus request after collapsing a shared sidebar collapse button.
  • Register route-appropriate main focus targets for workspace chat, project creation, scratch chats, settings, and analytics.
  • Avoid focusing targets inside inert/hidden regions.

Validation

  • bun test src/browser/hooks/useFocusMainRegion.test.tsx src/browser/components/SidebarCollapseButton/SidebarCollapseButton.test.tsx
  • bun test src/browser/components/ProjectPage/ProjectPage.autofocus.test.tsx src/browser/features/Settings/SettingsPage.test.tsx
  • make typecheck
  • make lint
  • make static-check was attempted but the workspace is missing uvx and hadolint; other static-check subtasks that ran passed, including formatting and code-to-docs links.

Risks

Low. The new event is route-scoped by whichever main route is mounted, and sidebar expansion does not request focus. The hidden/inert guard prevents immersive overlays from returning focus to a hidden composer.


Generated with Coder Agents on behalf of @tracyjohnsonux.

Copy link
Copy Markdown
Author

Closing because this change targeted the wrong repository. The requested fix belongs in coder/coder. Generated by Coder Agents on behalf of @tracyjohnsonux.

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.

1 participant