`<Select>` component `<form>` compatability
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 48/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Estagnada
- Stack de tecnologia
- react, typescript
- Domínio
- frontend
Direção de pesquisa
Comece pela implementação de e reproduza o problema usando o exemplo de formulário do CodeSandbox vinculado. Revise as issues 790 e 791 relacionadas de react-component/select para obter contexto sobre o comportamento do formulário. Está concluído quando um nomeado contribui com seu valor selecionado, incluindo seleções múltiplas, para o envio nativo do formulário sem alterar o uso existente.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- TypeScript
- Estrelas
- 939
- Forks
- 480
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de react-component/select
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
react-component/select#1216 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 45/100
react-component/select#1159 ·
-
a11y 问题Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
react-component/select#1087 · 1 reação ·
-
showSearch 默认值是 false 把Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 25/100
react-component/select#1086 ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 30/100
react-component/select#1082 · 1 comentário ·
Todas as issues de react-component/select
Issues semelhantes
-
ui(ListToolbar): search takes the full row on a phone instead of sharing it with the result countAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
Mantenedores costumam responder em até 1 dia
-
priority:high
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
immich-app/immich#32426 ·
Mantenedores costumam responder em até 1 dia
-
documentation good first issue hacktoberfest help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
libredb/libredb-studio#1756 ·
Mantenedores costumam responder em até 1 dia