preactjs / preact

⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.
https://preactjs.com
MIT License
36.69k stars 1.95k forks source link

react-big-calendar drag and drop/resizing feature does not work with Preact X #2427

Open craigdanj opened 4 years ago

craigdanj commented 4 years ago

Reproduction

react-big-calendar itself works fine in our project (that uses Preact X) but recently when we tried out the drag and drop add-on (http://jquense.github.io/react-big-calendar/examples/index.html#dnd) we realised it doesn't work as expected.

I tried it out in a separate project created on my local machine using preact-cli and we get the same behaviour there too.

Demos of it working with React: https://codesandbox.io/s/react-big-calendar-drag-and-drop-events-between-months-1sp9i http://jquense.github.io/react-big-calendar/examples/index.html#dnd

The preactX sandbox is given below https://codesandbox.io/s/preact-x-preact-cli-3-starter-ycqg4

I'm adding the npm output for the sandbox I created on my local machine using preact-cli. It exhibits the same broken behaviour on my local sandbox as it did in one of my other projects.

preact-sandbox@0.0.0 /Users/mgi-ui/Documents/Projects/preact-sandbox ├── enzyme-adapter-preact-pure@2.2.0 ├── eslint-config-preact@1.1.0 ├── jest-preset-preact@1.0.0 ├── UNMET PEER DEPENDENCY preact@10.3.4 ├── preact-cli@3.0.0-rc.10 ├── preact-render-spy@1.3.0 ├── preact-render-to-string@5.1.4 ├── preact-router@3.2.1 npm ERR! peer dep missing: preact@^8.1.0, required by preact-render-spy@1.3.0 npm ERR! peer dep missing: react@^16.6.1, required by react-big-calendar@0.24.1 npm ERR! peer dep missing: react-dom@^16.6.1, required by react-big-calendar@0.24.1 npm ERR! peer dep missing: webpack@4.28.4, required by babel-esm-plugin@0.7.1 npm ERR! peer dep missing: preact@^8.1.0, required by @preact/async-loader@3.0.0-rc.9 npm ERR! peer dep missing: react@^15.0.0 || ^16.0.0, required by react-hot-loader@4.12.20 npm ERR! peer dep missing: react-dom@^15.0.0 || ^16.0.0, required by react-hot-loader@4.12.20 npm ERR! peer dep missing: react@>=16.3.0, required by react-overlays@2.1.1 npm ERR! peer dep missing: react@>=15.0.0, required by uncontrollable@7.1.1 npm ERR! peer dep missing: react-dom@>=16.3.0, required by react-overlays@2.1.1 npm ERR! peer dep missing: react@^16.8.0, required by @restart/hooks@0.3.22 npm ERR! peer dep missing: react@>=15.0.0, required by uncontrollable@7.1.1

Steps to reproduce

  1. Add react-big-calnedar with its drag and drop addon to your Preact X project (as shown here https://github.com/jquense/react-big-calendar/blob/master/examples/demos/dnd.js).
  2. Drag an event from one day to the other.

Expected Behavior

As shown in the plugin demo here (http://jquense.github.io/react-big-calendar/examples/index.html#dnd), when you drag and event from one day and drop it on another the event gets moved to the day it was dropped on.

Resizing events also works.

Actual Behavior

I noticed when we drag an event (in week view) say from Monday and try to drop it on another day like Friday, as i drag the event it drops copies on every day my mouse moves over and then eventually drops it on the last day I release my mouse over too. This creates like multiple copies of events which shouldn't be the case.

For Month view its a little weirder. I start dragging and event and as I move my mouse over the calendar it adds the event to some days my mouse is passing over, some days it doesn't add the event to and when i drop the event it the "onEventDrop" handler points to the day that it last managed to add an event to. (Hope this isn't confusing).

Also resizing events doesn't work

Is anyone aware of a fix for this with PreactX?

developit commented 4 years ago

Hiya - sorry for the lack of a response on this. I'm guessing it has something to do with multiple render roots / portals in X. I tried some alternative approaches and versions and haven't found a solution yet.