ant-design: Support Missing `name` prop for ` element in dom when showSearch={false}

I am seeing an <input> element when showSearch={false} as well (video shows) Stackblitz Example: https://stackblitz.com/edit/react-ltsgbj?file=demo.js

https://user-images.githubusercontent.com/6743796/178735079-0bddf898-3843-492a-9909-08a9cd94b350.mp4

<Select> don’t support native name property

Is there a strong reason why we don’t support passing name prop on <Select> like we allow for <Input>?

  • Ant’s <Input> element:

    • ✅ supports name prop; follows standard behavior of HTML (docs)
    • ✅ because name prop is supported, you can wrap regular HTML <form> element around ant design elements
  • Ant’s <Select> element:

    • ❌ supports name prop; follows standard behavior of HTML (docs. For example a regular <select> element supports name
      CleanShot 2022-07-13 at 06 06 02@2x

    • ❌ because name prop is not supported, you cant wrap regular HTML <form> element around ant design elements (if name prop is supported this can be true ✅ )

Although I do care about the HTML standard, its not the motivation for this “bug” report.

The motivation is:

  • I can’t use a regular <form> around <Select> because it doesn’t allow me add a name prop to it.
    • There is no issue with ant’s <Input> which does support name prop which means I can use a regular <form>
  • I can’t use Remix’s <Form> element to do data submission’s because the name property is missing on <Select> element

🤦

I did the following:

A wrapper component (<MySelect>) for ant design’s Select-Component, that further has a hidden element. This has a name property as desired. In the wrapper i capture the onSelect() event from ant design’s <Select>, and in its event handler i update the value of the hidden .

Be aware however, that ant design’s Select has the option to select multiple values - you have to handle that accordingly, e.g by putting a comma-separated list into the value of the hidden

Am Mo., 15. Juli 2024 um 09:57 Uhr schrieb Ernest Sorinas < @.***>:

Hi! Does anyone know of a reasonable work-around to be able to use <Select> inside <form> and access the form values on submit?

— Reply to this email directly, view it on GitHub https://github.com/ant-design/ant-design/issues/36489#issuecomment-2227902654, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHZZQQAW5MDE6TXIT3SJTOTZMN6IBAVCNFSM53L7XRF2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMRSG44TAMRWGU2A . You are receiving this because you commented.Message ID: @.***>

– Dr. Michael Schröder Bergstr. 10 D-67688 Rodenbach phone +49 (0)6374 991328 fax +49 (0)6374 9271759 mobile +49 (0)173 5696695 @.***

I’m also interested in a solution, here. Since other Ant Design components support the name field, <Select> should as well.

It makes using Ant Design with Remix a good deal more complicated when Web HTML standards like name are not supported.

@afc163 - can we revisit this? Remix & NextJS rely on the expectation that a select element can have a name prop. The motivation is:

  • we cant use a regular <form> around <Select> because it doesn’t allow me add a name prop to it. There is no issue with ant’s <Input> which does support name prop which means I can use a regular <form>
  • we can’t use Remix’s <Form> element to do data submission’s because the name property is missing on <Select> element this is also standard HTML behavior and I outlined a solution to move forward

Kindly review the initial detailed issues description at the top of the page 🙏

I have the same issue with Remix + Antd and most of the projects I created are stuck on select element or data entry input which does not support native html input. I hope Antd team can solve this problem soon.

Need name for Select

Still No support?

looking for the same… Following

Why not support this? Is there any specific reason? We are using react-hook-form and it validates/controls form elements using the name property. I am pretty sure other form libraries and native form elements also use the name attribute for submission and validation.

So are you not going to support it?

Read more comments on GitHub
← ant-design: <Spin /> error when compiling css
ant-design: Switch: cannot get event object while fire click/change event →