Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#8,487 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@namangoyal176-10 がすでに取り組んでいます。

2026年10月6日 から。

  • #8508 @namangoyal176-10 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
react, typescript
領域
frontend, testing

調査の方向性

packages/react/src/FormControl/FormControl.tsx から始め、71–76 行目の input の検索と、138–159 行目の水平レンダリング分岐を確認します。提供されている水平および垂直の例を再現し、続いて水平の例に textbox が 1 つあることを検証するリグレッションテストを追加します。両方のレイアウトで input が 1 つレンダリングされれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
TypeScript
スター
3.9k
フォーク
697
平均マージ
3日 12時間
マージ済み PR(30日)
41

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

primer/react のほかの issue

primer/react の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。