Repository: ui
Issue: [bug]: Crashing website by tab indexing using Dialog and Select
Labels: bug

### Describe the bug

By pressing tab to focus the next input in a form can crash the application if its being used on a specific format.

Im opening a Dialog that has a Form inside requesting some sign up informations and when tab pressed twice after Select component focused it completely lags the browser.

I was doing some tests and it needs to be on a specific order to happen the error.   

### Affected component/components

Dialog, Form, Select, Input

### How to reproduce

<img width="1709" alt="Captura de Tela 2024-08-01 às 17 32 14" src="https://github.com/user-attachments/assets/0265c388-1310-4ffc-90d0-45106c647c6f">

To reproduce this error you simply need to create a Form within a Dialog, use a Select component and a Input just to tab index from one to another.

1. Open Dialog
2. With Select focused after dialog oppened, **press spacebar**
3. Press tab **(twice)** to go to the next input field

Note that it shows a ton of errors in loop.

Here is my code:

`return (
        <Dialog open={modalDependenteOpen} onOpenChange={setModalDependenteOpen}>
            <DialogTrigger asChild>
                <Button type="button" variant="outline" className="rounded-lg h-[35px] font-normal hover:bg-white/80">Adicionar aderente</Button>
            </DialogTrigger>
            <DialogContent>
                <DialogHeader>
                    <DialogTitle>Cadastrar aderente {(dependentes.length + 2).toString().padStart(2, '0')}</DialogTitle>
                    <DialogDescription>
                        Preencha as informações abaixo e clique no botão <span className="underline text-black font-bold">registrar</span>.
                    </DialogDescription>
                </DialogHeader>
                <Form {...form}>
                    <div className="flex flex-col gap-4">
                        <div className="flex flex-col gap-4 max-h-[calc(100dvh_-_200px)] p-2 border-y overflow-y-auto">
                            <FormField
                                control={form.control}
                                name="nome"
                                render={({ field }) => (
                                    <Select>
                                        <SelectTrigger className="w-full">
                                            <SelectValue placeholder="Informe o sexo do aderente" />
                                        </SelectTrigger>
                                        <SelectContent>
                                            <SelectItem value="m">Masculino</SelectItem>
                                            <SelectItem value="f">Feminino</SelectItem>
                                        </SelectContent>
                                    </Select>
                                )}
                            />
                            <FormField
                                control={form.control}
                                name="nome"
                                render={({ field }) => (
                                    <FormItem className="space-y-0">
                                        <FormLabel className="font-normal">Nome completo:</FormLabel>
                                        <FormControl>
                                            <Input placeholder="Digite o nome completo do aderente" {...field}/>
                                        </FormControl>
                                        <FormMessage className="text-xs text-red-500 font-normal">{errors.nome?.message}</FormMessage>
                                    </FormItem>
                                )}
                            />
                        </div>
                    </div>
                </Form>
            </DialogContent>
        </Dialog>
    )`

### Codesandbox/StackBlitz link

_No response_

### Logs

_No response_

### System Info

```bash
Macbook Pro, MacOS
```


### Before submitting

- [X] I've made research efforts and searched the documentation
- [X] I've searched for existing issues