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

SortableElement not using provided style #259

Closed
id0Sch opened this issue Aug 2, 2017 · 3 comments
Closed

SortableElement not using provided style #259

id0Sch opened this issue Aug 2, 2017 · 3 comments

Comments

@id0Sch
Copy link

id0Sch commented Aug 2, 2017

Hi,
i'm trying to follow the solution of the z-index issue (#87 (comment))
and i have the following component:

const SortableItem = SortableElement(({value}) => <div className="item" >{value}</div>)
const Sortable = SortableContainer(({items}) => {
  return <List className="list">
    {
      items.map((item, index) => <SortableItem key={item} index={index} value={item}
                                               style={{zIndex: 1000000}}/>)
    }
  </List>
})

and this is the generated html
image

it seems as if the SortableElement is creating another div that is created w/o the provided style.
am I missing anything?
Thanks.

@clauderic
Copy link
Owner

clauderic commented Aug 2, 2017

You need to pass the style attribute down to the div itself.

const SortableItem = SortableElement(({value, style}) => 
  <div className="item" style={style}>{value}</div>
)

Having said that, applying a zIndex of 1000000 to all of your elements might not be a great idea. Instead, I highly recommend you use the helperClass prop to selectively apply a high z-index to only the element that is currently being dragged

@id0Sch
Copy link
Author

id0Sch commented Aug 2, 2017

weird, setting the helperClass didn't work before so i tried the z-index solution.
but it did now..
thanks!

@SerKnight
Copy link

Yeah I found inline style to be easiest to persist css during drag.

<span style={{fontWeight:'bold', paddingRight: 5}}>{num +1})</span>
    {value}
</span>

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

3 participants