Skip to content

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