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

helperContainer prop cannot be used to support FullScreen API #476

Closed
garth opened this issue Jan 9, 2019 · 3 comments
Closed

helperContainer prop cannot be used to support FullScreen API #476

garth opened this issue Jan 9, 2019 · 3 comments

Comments

@garth
Copy link

garth commented Jan 9, 2019

PR #434 was closed without a working solution.

The helperContainer prop needs accept a function that is then evaluated when the drag begins to be sure that the current full screen status (not the full screen status at the time that the component was created) can be evaluated.

@clauderic
Copy link
Owner

Actually I do believe there is a working solution with the recently introduced updateBeforeSortStart prop. Something along these lines (untested) should probably work:

class App extends React.Component {
  state = {
    helperContainer: null, // or docucument.body for example
  };

  render() {
    return (
      <SortableContainer
        helperContainer={this.state.helperContainer}
        updateBeforeSortStart={() => new Promise(resolve => {
          const helperContainer = (
            document.fullscreenElement ||
            document.webkitFullscreenElement ||
            document.mozFullScreenElement ||
            document.msFullscreenElement ||
            document.body
          );

          this.setState({helperContainer}, resolve);
        })}
      />
    )
  }
}

As mentioned in #434, I'm not completely opposed to supporting this natively, but I'm not sure how common of a use-case this is.

@garth
Copy link
Author

garth commented Jan 10, 2019

Not really a good solution, since this will force an unnecessary additional render, it also requires the use of class components (until hooks arrive).

@clauderic
Copy link
Owner

Not really a good solution, since this will force an unnecessary additional render

I see your point, but unless your app has performance bottlenecks, this should be an extremely inexpensive additional render. This feels like an acceptable solution in the short term to me. In the future, I'll consider updating the helperContainer prop to accept a function.

It also requires the use of class components

react-sortable-hoc is a controlled component that already depends on state to manage the order of the elements, not sure how you would be using it without state in the first place (unless you're managing your state in Redux or something like that)

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

2 participants