Skip to content

fix: Drag preview visibility #976

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

Merged
merged 1 commit into from
Aug 6, 2024
Merged

fix: Drag preview visibility #976

merged 1 commit into from
Aug 6, 2024

Conversation

matthewlipski
Copy link
Collaborator

@matthewlipski matthewlipski commented Jul 30, 2024

Even though we've tried different approaches, we still keep seeing people have issues with the drag preview. Here's a summary of the things we've tried before and why they weren't ideal:

Displaying the drag preview element off-screen

This is recommended by Mozilla:

Note: If the Element is an existing HTMLElement it needs to be visible in the viewport in order to be shown as a drag feedback image. Alternatively, you can create a new DOM element that might be off-screen specifically for this purpose.

It works for most cases but isn't 100% reliable, as it causes bugs with some apps (@YousefED this was specifically an issue with DeepOrigin). Typically the issue is that the drag preview cuts off whatever part of the element is not within bounds of the screen.

Setting a negative drag preview z-index

This again works for most cases but not all, as the element will still be visible through any UI components that aren't fully opaque. See #966 for examples of this.

This PR makes the drag preview element get displayed at the top of the page with a very low opacity, which seems to be a more reliable fix than the previous approaches. Opacity has no effect of the drag preview itself unless the value is 0, in which case it becomes invisible. However, it works as expected for the drag preview element. This means that setting a very low opacity value makes the element functionally invisible without changing the drag preview at all. While this is a hack, it still seems to work better than the previous approaches, even though one of them is officially recommended.

Closes #966

Copy link

vercel bot commented Jul 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Jul 30, 2024 5:56pm
blocknote-website ✅ Ready (Inspect) Visit Preview Jul 30, 2024 5:56pm

@matthewlipski matthewlipski requested a review from YousefED July 30, 2024 17:56
@YousefED
Copy link
Collaborator

Nice find! I think the workaround is ok. What did we previously use to move the element off screen? I'm curious if a translate transform would work

@matthewlipski
Copy link
Collaborator Author

Nice find! I think the workaround is ok. What did we previously use to move the element off screen? I'm curious if a translate transform would work

Not quite, I'm still encountering issues with the DO code block:( So the opacity fix seems like the way to go

@YousefED YousefED merged commit 4a3b1cd into main Aug 6, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

Block Content Duplicated at Bottom of Page on Drag
2 participants