rkit / react-select2-wrapper

Wrapper for Select2
MIT License
163 stars 97 forks source link

Can't set class in dropdown container #71

Closed simonpay closed 7 years ago

simonpay commented 7 years ago

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 commented 7 years ago

Hi,

Any help on this would be appreciated.

Thanks

rkit commented 7 years ago

Do you use Webpack?

rkit commented 7 years ago

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

simonpay commented 7 years ago

Thanks for the reply.

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

simonpay commented 7 years ago

Thanks for the pointer in https://github.com/rkit/react-select2-wrapper/issues/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'),
      ],
    })
    ...