react-select icon indicating copy to clipboard operation
react-select copied to clipboard

[v2] `name` prop not applied to underlying `input` element?

Open eckdanny-osi opened this issue 7 years ago • 3 comments

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

[email protected]

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?

eckdanny-osi avatar Apr 25 '19 01:04 eckdanny-osi

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.

Rall3n avatar Apr 25 '19 10:04 Rall3n

+1

lommez avatar Jul 30 '19 18:07 lommez

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!

bladey avatar May 28 '20 06:05 bladey