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

Can't set class in dropdown container #71

Closed
simonpay opened this issue Jul 5, 2017 · 5 comments
Closed

Can't set class in dropdown container #71

simonpay opened this issue Jul 5, 2017 · 5 comments

Comments

@simonpay
Copy link

simonpay commented Jul 5, 2017

I'm trying to set a class in the generated select2 dropdown container via the dropdownCssClass option.

E.g.

<Select2
  ...
  options={{
    dropdownCssClass: 'my-class-name',
  }}
/>

I read that this option requires the full version of select2 to work.

I'm able to get it working by changing the code on line 29 of /react-select2-wrapper/lib/components/Select2.js from:

require('select2');

to:

require('select2/dist/js/select2.full');

Is there any way I can tell react-select2-wrapper to use the full version without hacking the package?

Thanks

@simonpay
Copy link
Author

Hi,

Any help on this would be appreciated.

Thanks

@rkit
Copy link
Owner

rkit commented Jul 14, 2017

Do you use Webpack?

@rkit
Copy link
Owner

rkit commented Jul 14, 2017

If you are using the webpack, please see this #8

@simonpay
Copy link
Author

Thanks for the reply.

I'm not using Webpack. Are there other options for me?

@simonpay
Copy link
Author

Thanks for the pointer in #8.

Based on this I used pathmodify to rewrite the path for select2 to the full version (I'm using browserify):

The relevant portion of my gulp task looks like this:

  ...
  return browserify('./src/app.js')
    /**
     * Use pathmodify to replace the reference to select2 with
     * the full version of the lib to support adding a class to
     * the generated dropdown markup.
     */
    .plugin(pathmodify, {
      mods: [
        pathmodify.mod.id('select2', 'select2/dist/js/select2.full'),
      ],
    })
    ...

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

No branches or pull requests

2 participants