[v2] `name` prop not applied to underlying `input` element?
I cannot retrieve the name when using the onBlur callback:
<Select
{...props}
name="myField"
onBlur={e => setTouched(e.target.name)}
/>
codesandbox: https://codesandbox.io/s/x39q6y6lrq?fontsize=14
Sure enough, the underlying input elem doesn't seem to have the name attribute set:
<!-- resulting DOM grabbed from ^ sandbox -->
<input
autocapitalize="none"
autocomplete="off"
autocorrect="off"
id="react-select-3-input"
spellcheck="false"
tabindex="0"
type="text"
aria-autocomplete="list"
value=""
style="box-sizing: content-box; width: 2px; background: 0px center; border: 0px; font-size: inherit; opacity: 1; outline: 0px; padding: 0px; color: inherit;"
/>
Bug?
The element you show from the sandbox is not the input element meant for name. This element is used for searching through the options and handling blur and focus of the Select component.
The element that receives the name prop is a hidden input element. It also receives the value attribute of the selected option as the value.
+1
Hello -
In an effort to sustain the react-select project going forward, we're closing old issues.
We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our efforts towards the current major version.
If you aren't using the latest version of react-select please consider upgrading to see if it resolves any issues you're having.
However, if you feel this issue is still relevant and you'd like us to review it - please leave a comment and we'll do our best to get back to you!