Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lost styles while dragging elements

I develop a project in React.js where I use react-sortable-hoc plugin for drag elements. I want to drag sections with inputs.

Before dragging it looks fine: before dragging

If I drag element, it looks like this: enter image description here

So styles in input, textarea and all form elements are lost while I dragging it.

Could you help me why styles lost and how I can fix it?

Thank you.

like image 687
Štefan Ondáš Avatar asked Mar 07 '26 04:03

Štefan Ondáš


1 Answers

When you dragging element, react-sortable-hoc plugin appends this element to body. If you have cascade in your styles, for example:

.parent-component .draggable-element {
 // some styles
}

This style will not apply because of in that moment element with draggable-element class don't be a child for element with parent-component class.

like image 59
Mikhail Shabrikov Avatar answered Mar 10 '26 06:03

Mikhail Shabrikov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!