-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
a11y: Move Focus to API Input Field When Agent Tool Selected #6708
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
…elector, instead of with autoFocus
04080b6
to
c8f9146
Compare
There might be a better way using |
This solution is not ideal due to direct dom/element manipulation, I will look into making this work natively with the components. if i can't find a reasonable solution soon, I will merge this |
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.
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
setTimeout(() => { | ||
const authField = document.querySelector('.auth-field') as HTMLInputElement; | ||
|
||
if (authField) { | ||
authField.focus(); | ||
} | ||
}, 100); |
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.
Using a fixed timeout delay may lead to timing issues, making the input focus behavior unreliable on slower devices. Consider using a React ref or a useLayoutEffect hook to trigger focus after the input is rendered.
setTimeout(() => { | |
const authField = document.querySelector('.auth-field') as HTMLInputElement; | |
if (authField) { | |
authField.focus(); | |
} | |
}, 100); | |
const authFieldRef = useRef<HTMLInputElement>(null); | |
useLayoutEffect(() => { | |
if (authFieldRef.current) { | |
authFieldRef.current.focus(); | |
} | |
}, [authFieldRef.current]); | |
const authField = document.querySelector('.auth-field') as HTMLInputElement; | |
if (authField) { | |
authFieldRef.current = authField; | |
} |
Copilot uses AI. Check for mistakes.
@danny-avila What do you think of the Copilot response? It is still using There are a few other issues I want to work on related to managing focus, but first want to see where we land with this one so I can reuse the same method. |
Closes #5505
Summary
After clicking an "Add" button on a specific Agent Tool, the text input in the auth form receives focus.
Change Type
Please delete any irrelevant options.
Testing
Test Configuration:
Checklist
Please delete any irrelevant options.