Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#8,487 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@namangoyal176-10 đang làm issue này rồi.

Từ ngày 6/10/2026.

  • #8508 của @namangoyal176-10 — đang mở
  • #8529 của @orpheusdark — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
84/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react, typescript
Lĩnh vực
frontend, testing

Hướng nghiên cứu

Bắt đầu trong packages/react/src/FormControl/FormControl.tsx, xem lại việc tìm kiếm input ở các dòng 71–76 và các nhánh rendering ngang ở các dòng 138–159. Tái hiện các ví dụ ngang và dọc được cung cấp, sau đó thêm một regression test để xác nhận rằng ví dụ ngang có một textbox; hoàn thành khi một input được render trong cả hai layout.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
TypeScript
Star
3.9k
Fork
697
Merge trung bình
3 ngày 12 giờ
Pull request đã merge (30 ngày)
46

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của primer/react

Tất cả issue của primer/react

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.