React-sortable-hoc: Why is the helper element added to the body and not the container?

Created on 22 Jun 2016  ·  3Comments  ·  Source: clauderic/react-sortable-hoc

If the helper is added to the container instead of the body, its relative styles will still be applied.

Most helpful comment

None of these points answer, why a custom container couldn't be provided as an optional prop

All 3 comments

There are a number of reasons for this, but long story short, it causes a lot more headaches than it solves. The challenges that arise when you try to append the element to the container instead of the body greatly outweigh the small benefits you get. Inevitably you end up needing a wrapper div to solve some of these challenges, which wouldn't make this component a HOC anymore. Feel free to try it for yourself :)

Also:

  • If you add the helper to it's container, it's susceptible to being hidden by overflow: scroll or overflow:hidden.
  • There are a number of css glitches in Safari on iOS related to fixed positioning nested elements.
  • Sometimes adding the helper to the container is simply not an option in the context of a HOC, for instance, if you're enhancing a react-virtualized or react-infinte list, nevermind the fact that touch events stop firing when the e.target gets removed from the DOM.

If you're using css-modules (if not, you should really give it a shot), this isn't really an issue either.

I see, thank you for this explanation.

None of these points answer, why a custom container couldn't be provided as an optional prop

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhujunwei picture zhujunwei  ·  3Comments

sami616 picture sami616  ·  4Comments

suhaotian picture suhaotian  ·  3Comments

ccharliemagne picture ccharliemagne  ·  3Comments

Jessidhia picture Jessidhia  ·  4Comments