kenshoo / react-multi-select

A Multi Select component built with and for React
https://kenshoo.github.io/react-multi-select
MIT License
120 stars 53 forks source link

Build version not compatible with Material UI #109

Open Cozloschi opened 6 years ago

Cozloschi commented 6 years ago

Expected Behavior

Hello, I am using your multi select component in a project which uses Material UI. On the development server everything looks like expected:

screen shot 2018-10-25 at 11 14 10

When I am using production build, everything looks the same except the component which uses your component:

screen shot 2018-10-25 at 11 13 55

Do you have any ideea why this happens? Thank you in advance.

Steps to Reproduce the Problem

  1. Add material ui to a project
  2. Insert your component into a dialog box
  3. Open dialog box

Specifications

talyak commented 6 years ago

I am checking it, can u please add code example how do you try to use it?

Cozloschi commented 6 years ago

Thank you for your reply. Here's an example of my render function:

render() {
        return (
            <div>
                <Dialog
                    open={this.props.open}
                    aria-labelledby="form-dialog-title"
                    className={this.props.className}
                    fullWidth={true}
                    maxWidth={this.props.maxWidth}
                >
                    <DialogTitle id="form-dialog-title">{this.props.dialogTitle}</DialogTitle>
                    <DialogContent>
                        {this.props.dialogText ? <DialogContentText>
                            {this.props.dialogText}
                        </DialogContentText> : null}
                        {this.renderFields()}
                        {this.props.multiSelect && <MultiSelect
                            wrapperClassName='modalBoxMultipleSelect'
                            items={this.props.multiSelectItems}
                            selectedItems={this.state.selectedItems}
                            onChange={items => this.handleChangeSelectItem(items)}
                        />}
                    </DialogContent>
                    <DialogActions>
                        <Button onClick={this.handleClose} color="primary">
                            Cancel
                        </Button>
                        <Button onClick={() => this.saveChanges()} color="primary">
                            {this.props.submitButtonText}
                        </Button>
                    </DialogActions>
                </Dialog>
            </div>
        )
    }

I've seen that your project uses Material UI also, and from what I've read there might be css conflicts if there's two instances of material UI on the same project. https://github.com/marmelab/react-admin/issues/1782

I will try using Material UI as a peer dependency.

talyak commented 6 years ago

update me please.

Cozloschi commented 6 years ago

Using Material Ui as a peer dependency didn't work. But wrapping my entire project in a JssProvider component did the trick. https://github.com/marmelab/react-admin/issues/1782#issuecomment-418633547

import JssProvider from 'react-jss/lib/JssProvider';

export default () => (
    <JssProvider generateClassName={generateClassName}>
        <App />
    </JssProvider>
);

I think that we should consider wrapping your project in a JssProvider, maybe this way won't be any conflicts in the future with other projects using Material UI.

uikenshoo commented 6 years ago

Thank you @Cozloschi for bringing this to our attention. We hope to release a new version soon that will ensure that material ui is a proper peer dependency and will use whatever version you've provided in your application.

You are also more then welcomed to provide a solution beforehand, any contribution would be greatly appreciated.

orShapira commented 5 years ago

Same issue here! would love to have a fix soon 👍

liorheber commented 5 years ago

Sorry about the delay in handling this. I think we can commit to fixing this next week.

orShapira commented 5 years ago

is there any news with this issue? I'm literally unable to use this component. and it was a really good one before!

Zidanela commented 5 years ago

any updated?

Zidanela commented 5 years ago

we've been waiting for the bug fix :(.

liorheber commented 5 years ago

Hi, hopefully this PR will provide the fix. https://github.com/kenshoo/react-multi-select/pull/126 Should be merged today.

liorheber commented 5 years ago

Please give v1.0.67 and let us know how it goes.

Thanks!

orShapira commented 5 years ago

Hi, this issue is still going

  1. it damaged other material-ui components behavior - such as Dialog and more...
  2. it's behavior and look itself are not as good as the development environment

image

liorheber commented 5 years ago

@orShapira what material ui version are you using?

orShapira commented 5 years ago

@liorheber my stable production work with @material-ui/core:3.1.2 but I also upgraded the staging environment to @material-ui/core:3.9.2 and it also didn't work

liorheber commented 5 years ago

Well the dependency for our component is currently material-ui/core@1.0.0 so there's a good chance this is the cause. @yegor-babiy is planning on looking into this this coming week and there's a good chance we'll update the dependency if that proves to be the root cause. We will update as soon as possible but you are also welcomed to give it a try.

yegor-babiy commented 5 years ago

@orShapira could you please supply a live code example, because we still can't reproduce issue on our end.

samuelrego commented 5 years ago

Hi, I am using material ui 3.9.2 version. but multi-select library uses 1.0 version. it's giving me a lot of errors. is there any solution for this??

yegor-babiy commented 5 years ago

@samuelrego thanks for feedback, could you please provide more details, which errors you got, that we had ability to reproduce such issue.

baptwaels commented 5 years ago

I've tried with v1.0.71 using material-ui v1.3.0, still having the issue

Edit: I've used a JSSProvider instead (custom generateClassName), it works like a charm. Thanks :)

giancarlobianchi12 commented 5 years ago

Same problem here ! Any solution in production mode ? I'm using "@kenshooui/react-multi-select": "^1.1.3", "@material-ui/core": "^3.9.3",

ekinertac commented 4 years ago

problem still exists

"@kenshooui/react-multi-select": "^1.1.6",
"@material-ui/core": "^4.11.0",
rickyalmeidadev commented 3 years ago

@ekinertac I am facing the same problem on the same versions. Did you find any solution?