File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ let keyword = ''
1010
1111export default function App ( ) {
1212 const dialogRef = useRef < HTMLDialogElement > ( null )
13+ const inputRef = useRef < HTMLInputElement > ( null )
1314 const [ comments , setComments ] = useState < Reply [ ] > ( )
1415 const promiseRef = useRef < Promise < Reply [ ] > | null > ( null )
1516
@@ -33,7 +34,7 @@ export default function App() {
3334 < button onClick = { ( ) => dialogRef . current ?. close ( ) } > X</ button >
3435 </ div >
3536 < input
36- autoFocus
37+ ref = { inputRef }
3738 placeholder = '搜索评论'
3839 onKeyDown = { ( e ) => {
3940 if ( e . key === 'Enter' && promiseRef . current ) {
@@ -57,6 +58,7 @@ export default function App() {
5758 < button
5859 onClick = { ( ) => {
5960 dialogRef . current ?. showModal ( )
61+ inputRef . current ?. focus ( )
6062 const videoId = extractVideoId ( window . location . href )
6163 promiseRef . current = fetchComments ( videoId )
6264 } }
You can’t perform that action at this time.
0 commit comments