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

zIndex stutters to lower values when using multiple Rnd elements #80

Closed
aconanlai opened this issue Mar 2, 2017 · 1 comment
Closed

Comments

@aconanlai
Copy link

I'm building a web app that uses multiple Rnd elements at once to replicate a desktop experience - multiple draggable icons, and draggable + resizable 'windows'. Clicking on windows that are 'in the background' brings them to the forefront by tracking the 'highest zIndex' and adding to that. However, sometimes, when an element in already in the foreground, clicking on it (and thus firing the onDragStart and onDragEnd events in the Rnd element) causes the zIndex to momentarily switch to the same value as an element 'lower' on the screen. Through the React state/prop tree, new zIndex values haven't been passed down to any elements, but the react-draggable div's inline styles are changing. After digging into the source a bit, I'm finding it's caused by line 216 here:
https://github.com/bokuweb/react-rnd/blob/master/src/index.js

<div style={Object.assign(boxStyle, { zIndex })}>

I was able to solve this problem by just inlining the whole object instead of using Object.assign - I didn't have time to delve further to figure out if this is the right way to go about it, if I find time at some point I'll try to submit a pull request, but if someone wants to check this out, feel free.

@kudlajz
Copy link
Contributor

kudlajz commented Apr 25, 2017

@aconanlai I've made a fix, did it help? Can you try it?

@bokuweb bokuweb closed this as completed Jun 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants