`<Select>` component `<form>` compatability
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- react, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Bắt đầu với phần triển khai và tái hiện vấn đề bằng ví dụ form CodeSandbox được liên kết. Xem các issue 790 và 791 liên quan của react-component/select để hiểu bối cảnh về hành vi của form. Công việc được xem là hoàn tất khi một có tên đóng góp giá trị đã chọn của nó, bao gồm cả các lựa chọn multiple, vào việc gửi form native mà không thay đổi cách sử dụng hiện có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 938
- Fork
- 482
- Merge trung bình
- 15 giờ 8 phút
- Pull request đã merge (30 ngày)
- 2
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
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 react-component/select
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
react-component/select#1216 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
react-component/select#1159 ·
-
a11y 问题 Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
react-component/select#1087 · 1 reaction ·
-
showSearch 默认值是 false 把 Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
react-component/select#1086 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
react-component/select#1082 · 1 bình luận ·
Tất cả issue của react-component/select
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
vercel-labs/just-bash#464 ·
-
looksLikeSlug() is ASCII-only, so non-Latin entity slugs (e.g. Korean) skip exact match and collapse Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
TanStack/tanstack.com#1293 ·