`<Select>` component `<form>` compatability
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- react, typescript
- Bereich
- frontend
Rechercherichtung
Beginne mit der Implementierung von und reproduziere das Problem anhand des verknüpften CodeSandbox-Formularbeispiels. Sieh dir die zugehörigen react-component/select-Issues 790 und 791 an, um den Kontext zum Formularverhalten zu erhalten. Als erledigt gilt die Aufgabe, wenn ein benanntes seinen ausgewählten Wert, einschließlich mehrerer Auswahlen, zur nativen Formularübermittlung beiträgt, ohne die bestehende Verwendung zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Description
Currently <Select> component is not fully <form> compatible, which means when you submit a <Form> or <form> the data from the <Select> is not included in the form submission.
How to Reproduce Bug
Submit a form which contain's <Select> (see video below or see codesandbox here)
- observe that form submission does not update the URL
- observe that no data is being sent to the backend
Motivation For Changes
1. HTML <form> compatibility
- Being
<form>compliant means that people have the additional option of using Ant's<Select>in a similar way to using a standard<select>without losing the great UX/UI that<Select>offers (for example using<Select showSearch>is awesome!)
2. Many of Ant design's existing form-related components are already <form> compliant
<Input>,<InputNumber>and<Mentions>are already<form>compliant- codesandbox testing
<form>compliance of components above https://codesandbox.io/s/draft1-testing-ant-form-compatability-forked-z35rhu?file=/app/routes/examples/checkbox-component.tsx
- Removes the need for a user of Ant Design to manually add hidden input fields . This is the same issue Tailwind Headless UI had but solved in this pull request
Proposition of Changes
The proposed changes below are backwards compatible:
-
allow user to pass
nameprop to<Select>to achieve feature compliance with regular<select>which does allownameprop (Ex:<select name="vehicle">).

-
When a user passes
nameprop to<Select>generate a hidden input (<input type="hidden" name={selectProps.name}>) and when the user selects the value from the list, addvalueattribute to the hidden input and set it to the selected value (<input type="hidden" name={selectProps.name} value={selected_value}>. Inspiration for this implementation comes from Tailwind's Headless UI react library (Github Pull Request)
For single item selection (fake code for demonstrative purpose)
<Select showSearch style={{ width: 300 }} name="job_title">
<Select.Option value="engineer">engineer</Select.Option>
<Select.Option value="teacher">teacher</Select.Option>
// This hidden input would get generated from <Select> when a `name` prop is provided
// <input type="hidden" name={select.props.name} value={the_selected_value}>
</Select>
For multi selection (fake code for demonstrative purpose) mode=tags | multiple
<Select showSearch style={{ width: 300 }} name="job_title">
<Select.Option value="engineer">engineer</Select.Option>
<Select.Option value="teacher">teacher</Select.Option>
// Any time a new item is selected a new hidden input is generated from <Select> when a `name` prop is provided
// <input type="hidden" name={select.props.name} value={the_selected_value}>
// <input type="hidden" name={select.props.name} value={the_selected_value}>
</Select>
Summary
To solve this, <Select> needs name prop support & it needs to generate a hidden <input> element for the selected value
References
Documentation for <form> comptability
<form>compatibility example Github Pull request for tailwind React UI library + example tests- documentation for `
Related Issues
- Vorherrschende Sprache
- TypeScript
- Sterne
- 938
- Forks
- 482
- Ø Merge
- 15 Std. 8 Min.
- Gemergte PRs (30 T.)
- 2
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus react-component/select
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
react-component/select#1216 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 45/100
react-component/select#1159 ·
-
a11y 问题 Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
react-component/select#1087 · 1 Reaktion ·
-
showSearch 默认值是 false 把 Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 25/100
react-component/select#1086 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 30/100
react-component/select#1082 · 1 Kommentar ·
Alle Issues in react-component/select
Ähnliche Issues
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
-
Mend: dependency security vulnerability untriaged
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100