Skip to content

Commit 16f7f63

Browse files
authored
Disable auto focus on title in mobile open pull request dialog (#152)
Co-authored-by: Chris Tate <ctate@users.noreply.github.com>
1 parent 5bb4fbd commit 16f7f63

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

components/create-pr-dialog.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { useState } from 'react'
3+
import { useState, useEffect } from 'react'
44
import { Button } from '@/components/ui/button'
55
import {
66
Dialog,
@@ -36,6 +36,19 @@ export function CreatePRDialog({
3636
const [title, setTitle] = useState(defaultTitle)
3737
const [body, setBody] = useState(defaultBody)
3838
const [isCreating, setIsCreating] = useState(false)
39+
const [isMobile, setIsMobile] = useState(false)
40+
41+
useEffect(() => {
42+
// Check if the device is mobile
43+
const checkMobile = () => {
44+
setIsMobile(window.innerWidth < 768)
45+
}
46+
47+
checkMobile()
48+
window.addEventListener('resize', checkMobile)
49+
50+
return () => window.removeEventListener('resize', checkMobile)
51+
}, [])
3952

4053
const handleSubmit = async (e: React.FormEvent) => {
4154
e.preventDefault()
@@ -103,6 +116,7 @@ export function CreatePRDialog({
103116
value={title}
104117
onChange={(e) => setTitle(e.target.value)}
105118
disabled={isCreating}
119+
autoFocus={!isMobile}
106120
/>
107121
</div>
108122
<div className="grid gap-2">

0 commit comments

Comments
 (0)