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

Support hidden property on option and optgroup elements. #2903

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Mikk3lRo
Copy link
Contributor

@Mikk3lRo Mikk3lRo commented Oct 7, 2017

Summary

Add support for the hidden attribute on options and optgroups.

It probably has other applications, and I don't see any reason not to support it anyway - but my primary motivation is to make it easier to provide a graceful fallback on devices that Chosen does not support.

Placeholders in native selects can be more or less correctly "simulated" in all modern browsers by setting the selected, disabled and hidden props on the first option: StackOverflow answer

Without this patch Chosen still shows the option though.

If we simply read and respect the hidden attribute, it all works perfectly.

So some sort of placeholders can be shown on all devices, even those Chosen does not support using markup like this:

<select data-placeholder="This is my placeholder">
  <option value="" disabled hidden selected>This is my placeholder</option>
  <option value="opt1">Option 1</option>
</select>

I'm fairly certain there are no negative side effects of supporting this attribute.

  • All changes were made in CoffeeScript files, not JavaScript files.
  • You used Grunt to build the JavaScript files and tested them locally.
  • You've updated both the jQuery and Prototype versions.
  • You haven't manually updated the version number in package.json.
  • If necessary, you've updated the documentation.

@JJJ JJJ mentioned this pull request Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant