Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic placeholders for Multi-select no longer working in 9.x #779

Open
travist opened this issue Nov 25, 2019 · 6 comments
Open

Dynamic placeholders for Multi-select no longer working in 9.x #779

travist opened this issue Nov 25, 2019 · 6 comments
Labels

Comments

@travist
Copy link
Contributor

travist commented Nov 25, 2019

Describe the bug
In all versions <= 8.0.0, placeholders would show up for multiple select dropdown configurations. This is no longer working in the 9.x branch.

To Reproduce
Steps to reproduce the behavior:

  1. Add a new multi-select with no initial options.
  2. Use the following code to add placeholder.
<select id="myselect"></select>
new Choices(document.getElementById('myselect'), {
  placeholderValue: 'This should be a placeholder'
});

Expected behavior
You should see the placeholder.

Screenshots
Will provide if necessary but this is pretty easy to reproduce.

Desktop (please complete the following information):

  • MacOS, Chrome
@travist travist added the bug label Nov 25, 2019
@alfonsoar
Copy link

I am also hitting this bug

@jshjohnson
Copy link
Collaborator

jshjohnson commented Nov 28, 2019

Hey - so I actually removed this functionality in the 9.0.0 release (#731) but have clearly forgotten to update the documentation 🤦‍♂For versions >=9.x, placeholderValue will only apply to text elements. The reason for removing it was the added complexity of supporting it.

@travist
Copy link
Contributor Author

travist commented Dec 3, 2019

This can be done by just adding a "placeholder" attribute on the input element that is part of the multi-select. This would normally be done via configurations, but the issue the current branch has it is does not default to the placeholder configurations if the select element does not have a "default" select option. The following pull request fixes this issue with minimal changes.

#788

@evenfrost
Copy link

@jshjohnson then what is the current way to add a placeholder to multiselect? searchPlaceholderValue does not work either.

@travist
Copy link
Contributor Author

travist commented Apr 22, 2020

@evenfrost
Copy link

@travist thanks. I've ended with dumb'n'brute solution (using Preact):

  useEffect(() => {
    const choices = new Choices(selectRef.current, options as IChoices.Options);
    
    if (restProps.multiple && choices.config.placeholderValue) {
      ((choices as any).input as HTMLInputElement).placeholder = choices.config.placeholderValue;
    }
  }, []);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants