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

Hide create new option prompt text when input is empty/reset/cleared

Open kukikiloke opened this issue 9 years ago • 10 comments

Preconditions:

  • multi: true
  • createable: true

Steps:

  1. Type something which will show some of the options, select any of the options.
  2. Input is cleared on selecting option but the prompt text Create an option "xxx" is still there when you focus on the field. The same happens when you type something and click outside of the select container (blur) and focus on it again.

It would be great if the prompt text Create an option "xxx" will not display when the input is empty/reset/cleared as it's kinda strange to display suggestion to create new option when there is nothing in the input. Thanks!

kukikiloke avatar Feb 22 '17 23:02 kukikiloke

+1

slavab89 avatar Mar 04 '17 18:03 slavab89

+1

shoaibbhimani avatar Mar 06 '17 12:03 shoaibbhimani

A quick (and dirty?) workaround currently is to manually delete the internal placeholder item whenever onChange() fires.

Here's an example using a stateless component:

export default props => {
  let ref;

  return (<Select.Creatable ref={el => ref = el}
                            onChange(values => {
                              delete ref._createPlaceholderOption;
                              //resume handling the values
                            }/>)
}

tonisostrat avatar Mar 09 '17 12:03 tonisostrat

@tonisostrat why not simply hide element based on its class .Select-menu-outer .Select-create-option-placeholder { display: none; }

shoaibbhimani avatar Mar 09 '17 14:03 shoaibbhimani

Because that only hides it visually. It's still persisted inside the <Select/> and may affect the behaviour of the whole field in regards to filtering the drop-down and item creation/selection.

tonisostrat avatar Mar 09 '17 15:03 tonisostrat

+1

dmitrykuznetsovdev avatar Apr 05 '17 17:04 dmitrykuznetsovdev

+1

thejjmiller avatar Apr 21 '17 18:04 thejjmiller

+1!

@tonisostrat Your workaround doesn't work for me :(

lorenzos avatar Jul 19 '17 13:07 lorenzos

To me, this is fixed with #1306. Close?

lorenzos avatar Jul 27 '17 08:07 lorenzos

Hello -

In an effort to sustain the react-select project going forward, we're closing old issues / pull requests.

We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our limited efforts to maintain the latest version.

If you feel this issue / pull request 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 27 '20 06:05 bladey