Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

FormControl renders duplicate non-choice inputs when layout="horizontal"

Abierto Apto para principiantes
#8,487 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

@namangoyal176-10 ya está trabajando en esto.

Desde el 6/10/2026.

  • #8508 de @namangoyal176-10 — abierto
  • #8529 de @orpheusdark — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
84/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
react, typescript
Área
frontend, testing

Línea de trabajo

Comienza en packages/react/src/FormControl/FormControl.tsx revisando la búsqueda de input en las líneas 71–76 y las ramas de renderizado horizontal en las líneas 138–159. Reproduce los ejemplos horizontal y vertical proporcionados y, a continuación, añade una prueba de regresión que compruebe que el ejemplo horizontal tiene un textbox; se considera completado cuando se renderiza un input en ambos layouts.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
Description

FormControl's horizontal layout includes the same non-choice input twice in its render output.

The component finds the input in childrenWithoutSlots and renders a cloned version of it. However, the subsequent filter only excludes Checkbox and Radio, leaving non-choice inputs such as TextInput, Textarea, and Select in the remaining children. The original input is therefore rendered alongside the clone.

Expected behavior:
A FormControl containing one input should render exactly one input, regardless of whether its layout is horizontal or vertical.

Actual behavior indicated by the source:
With layout="horizontal" and a direct TextInput child, both the cloned TextInput and the original TextInput are included in the render output.

Relevant code in packages/react/src/FormControl/FormControl.tsx:

  • Lines 71–76: find the input without removing it from childrenWithoutSlots.
  • Lines 138–154: render the cloned input.
  • Lines 155–159: render remaining children, excluding only Checkbox and Radio.

The vertical branch excludes all expectedInputComponents and does not have this duplication.

This report is based on source inspection of commit 8c0b708fc. Browser reproduction has not yet been performed.

Steps to reproduce
  1. Render the following example using the affected source checkout:
import {BaseStyles, FormControl, TextInput, ThemeProvider} from '@primer/react'

export default function App() {
  return (
    <ThemeProvider>
      <BaseStyles>
        <FormControl layout="horizontal">
          <FormControl.Label>Name</FormControl.Label>
          <TextInput />
        </FormControl>
      </BaseStyles>
    </ThemeProvider>
  )
}
  1. Inspect the rendered inputs inside FormControl.
  2. The horizontal branch is expected to produce two text inputs despite only one TextInput being supplied.
  3. Change layout to "vertical" and compare: the vertical branch should render only one text input.

A regression test can assert that getAllByRole('textbox') has a length of 1 for the horizontal example.

Version

38.40.0

Browser

No response

Lenguaje dominante
TypeScript
Estrellas
3.9k
Forks
697
Merge medio
2 d 17 h
PR fusionados (30 d)
37

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de primer/react

Todos los issues de primer/react

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.