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

onDragOverClassName styles not removed when files are not dropped #354

Closed
AJLemos opened this issue Apr 8, 2022 · 9 comments · Fixed by #356
Closed

onDragOverClassName styles not removed when files are not dropped #354

AJLemos opened this issue Apr 8, 2022 · 9 comments · Fixed by #356
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@AJLemos
Copy link

AJLemos commented Apr 8, 2022

Describe the bug

The onDragOverClassName applied to the <UploadDropZone> component is not removed when files are hovered over the browser, but instead of being dropped are moved back to the finder window.

This is on MacOS (I have not tested Windows yet).

To Reproduce
Steps to reproduce the behavior:

  1. Drag one or more files over the drop zone created by <UploadDropZone>
  2. Instead of dropping the files, move them back to the finder window

Expected behavior

The drop target styles, applied via the onDragOverClassName, should be removed.

Versions

@rpldy/upload-drop-zone: 0.18.1
@rpldy/uploady: 0.18.1

Code

Here is a codesandbox with a simplified implementation: https://codesandbox.io/s/vigorous-https-wd9web?file=/src/App.js

Here is a video showing the current behavior: https://share.getcloudapp.com/7KuQ6Rqx

I haven't debugged the drop zone code, but it looks like the event target may no longer be the drop zone when moving files back to the the finder window, here: https://github.com/rpldy/react-uploady/blob/master/packages/ui/upload-drop-zone/src/UploadDropZone.js#L75

@yoavniran
Copy link
Collaborator

Hey @AJLemos
I think the issue here is that your indicator overlay covers the entire page.
I will look into fixing this

thanks

@yoavniran
Copy link
Collaborator

@AJLemos With your example (very useful), and as I suspected, I've identified the issue as having to do with the nature of showing an overlay across the d&d area.

I dont think there's a clean way for me to consistently remove the drag-over class without user-code help, and also support other use-cases and edge-cases.

So, I suggest that I'll provide an optional callback prop that you can implement in order to help the DropZone component.
Notice the shouldRemoveDragOver callback that I suggest adding:

const Example = () => {
    const indicatorRef = useRef(null);

    return <Uploady >
        <UploadDropZone 
               id="upload-drop-zone" 
               onDragOverClassName="drag-over"
               shouldRemoveDragOver={(target) => target === indicatorRef.current}
        >
            <div className="content">
                <h1>Drop files here</h1>
            </div>
            <div className="dropIndicator" aria-hidden ref={indicatorRef} />
        </UploadDropZone>
    </Uploady>;
};

What do you think?

@yoavniran yoavniran self-assigned this Apr 9, 2022
@yoavniran yoavniran added bug Something isn't working enhancement New feature or request labels Apr 9, 2022
@yoavniran
Copy link
Collaborator

@mwdiaz
Copy link

mwdiaz commented Apr 11, 2022

@yoavniran thanks for the quick fix! I work with AJ (he's out on vacation for a couple weeks), and I'll make time today to pull in the new version and verify that it works well for our use case.

@yoavniran
Copy link
Collaborator

thanks @mwdiaz
Out of curiosity, where do you guys work/use Uploady?

@mwdiaz
Copy link

mwdiaz commented Apr 12, 2022

@yoavniran I just applied the update and it works nicely! We work at SmugMug, and we're using Uploady as the foundation for building out a refreshed uploader UI in our newer codebase.

@yoavniran
Copy link
Collaborator

awesome, thanks for sharing :)
Glad to hear it works

@yoavniran
Copy link
Collaborator

BTW, if SmugMug wants to become an Uploady sponsor, I'd be very happy to promote it here on GH and the Uploady site.

@mwdiaz
Copy link

mwdiaz commented Apr 15, 2022

BTW, if SmugMug wants to become an Uploady sponsor, I'd be very happy to promote it here on GH and the Uploady site.

Thanks, the library has been awesome for us so far! I'm looking into what we can offer as far as sponsoring the project, stay tuned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants