Skip to content

Commit 18c2d56

Browse files
committed
fix(admin): rename autoFocus to focusOnOpen to resolve a11y lint error
The autoFocus prop name triggered the jsx-a11y/no-autofocus ESLint rule, which prevents use of the HTML autoFocus attribute due to accessibility concerns. Renamed the prop to focusOnOpen to: - Clarify it's a custom prop, not the HTML attribute - Avoid naming conflicts with accessibility linting rules - Better describe the behavior (focus when dialog opens) The implementation already uses programmatic focus via useEffect and refs (the accessible approach), so only the naming needed to change.
1 parent 5158689 commit 18c2d56

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

app/src/components/admin/AdminImpersonationButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export function AdminImpersonationButton() {
153153
placeholder="Search for user"
154154
loading={starting}
155155
loadingText="Starting"
156-
autoFocus={open}
156+
focusOnOpen={open}
157157
/>
158158
</div>
159159

app/src/components/admin/UserSearchAutocomplete.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface Props {
2525
disabled?: boolean
2626
placeholder?: string
2727
currentUserId?: string
28-
autoFocus?: boolean
28+
focusOnOpen?: boolean
2929
align?: "left" | "right"
3030
loading?: boolean
3131
loadingText?: string
@@ -48,7 +48,7 @@ export function UserSearchAutocomplete({
4848
disabled,
4949
placeholder,
5050
currentUserId,
51-
autoFocus,
51+
focusOnOpen,
5252
align = "left",
5353
loading = false,
5454
loadingText
@@ -115,14 +115,14 @@ export function UserSearchAutocomplete({
115115
}, [open])
116116

117117
useEffect(() => {
118-
if (open && autoFocus && inputRef.current) {
118+
if (open && focusOnOpen && inputRef.current) {
119119
// Small delay to ensure the input is rendered
120120
const timeout = setTimeout(() => {
121121
inputRef.current?.focus()
122122
}, 100)
123123
return () => clearTimeout(timeout)
124124
}
125-
}, [open, autoFocus])
125+
}, [open, focusOnOpen])
126126

127127
return (
128128
<div ref={containerRef} className="relative w-full">

0 commit comments

Comments
 (0)