-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: gate auto-focus behavior with preventFocusDisruption experiment #10529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This addresses the focus-stealing behavior on initial load that violates WCAG 3.2.1 and 3.2.2 accessibility criteria. Changes: - ChatTextArea.tsx: autoFocus now respects preventFocusDisruption flag - ChatView.tsx: didBecomeVisible focus call gated by flag - ChatView.tsx: useDebounceEffect focus call gated by flag The fix uses the existing preventFocusDisruption experiment flag which users can enable in Settings > Experimental to prevent focus disruption. Closes #10492
Review complete. No issues found. The implementation correctly gates auto-focus behavior behind the existing Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
lemiesz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally this appears to fix the issue.
Review complete. No issues found. The implementation correctly gates auto-focus behavior behind the existing Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Related GitHub Issue
Closes: #10492
Roo Code Task Context (Optional)
This PR was created with assistance from Roo Code.
Description
This PR attempts to address Issue #10492 by gating the auto-focus behavior behind the existing
preventFocusDisruptionexperiment flag.Changes made:
autoFocus={true}toautoFocus={!experiments?.preventFocusDisruption}so the textarea only auto-focuses when the experiment is disabled (default behavior)didBecomeVisibleaction handler so it only focuses when the experiment is disableduseDebounceEffecthook that auto-focuses the textarea, also adding the experiment flag to the dependency arrayThe fix reuses the existing
preventFocusDisruptionexperiment flag which was previously only used for diff view operations. Users can enable this via Settings > Experimental > Prevent Focus Disruption to prevent focus stealing during initial load.Test Procedure
preventFocusDisruptionexperiment in Settings > ExperimentalAutomated tests:
cd webview-ui && npx tsc --noEmit- passedcd webview-ui && npx eslint src/components/chat/ChatView.tsx src/components/chat/ChatTextArea.tsx --max-warnings=0- passedcd webview-ui && npx vitest run src/components/chat- 298 tests passedPre-Submission Checklist
Screenshots / Videos
N/A - This is a behavior change (focus management) rather than a visual change.
Documentation Updates
Additional Notes
Feedback and guidance are welcome. This implementation follows the plan outlined in the original issue comment.
Get in Touch
Please mention @roomote in the PR comments for questions.
Important
Gate auto-focus behavior in
ChatTextArea.tsxandChatView.tsxwithpreventFocusDisruptionexperiment flag to prevent focus stealing.ChatTextArea.tsx: ChangeautoFocus={true}toautoFocus={!experiments?.preventFocusDisruption}to conditionally auto-focus the textarea.ChatView.tsx: Add gating todidBecomeVisibleaction handler anduseDebounceEffecthook to conditionally focus the textarea based on the experiment flag.preventFocusDisruptionexperiment flag, previously used for diff view operations, to manage focus behavior in chat components.This description was created by
for 6a315cd. You can customize this summary. It will automatically update as commits are pushed.