FormControl renders duplicate non-choice inputs when layout="horizontal"
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.
Đá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
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ả
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
- 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>
)
}
- Inspect the rendered inputs inside FormControl.
- The horizontal branch is expected to produce two text inputs despite only one TextInput being supplied.
- 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
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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của primer/react
-
PageHeader.Title does not seem to accept id propCó thể đã có người làm @minwookshin đã nhận 14 ngày trước. Đang mởcomponent: PageHeader react staff
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
primer/react#8474 · 1 bình luận · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
The padding prop seems to have no effect with PageLayout.SidebarCó thể đã có người làm @minwookshin đã nhận 14 ngày trước. Đang mởcomponent: PageLayout react staff
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
primer/react#8470 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug component: Spinner react
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
primer/react#8423 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Low contrast in SelectĐang mởwaiting for author response
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
primer/react#8172 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Checkbox: replace useLayoutEffect with ref callback for indeterminate propCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởcomponent: Checkbox react
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
Issue tương tự
-
Bump anybuf version to ^1.0.0Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
wormhole-foundation/wormhole#5062 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
internal os specific
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
frostney/GocciaScript#1688 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
integration:hermes
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
vectorize-io/hindsight#5592 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
vercel/streamdown#673 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
apache/rocketmq-dashboard#6712 ·
Maintainer thường phản hồi trong vòng 3 ngày