-
Notifications
You must be signed in to change notification settings - Fork 20
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
fix(visual-editing): unset overlay applied cursor on mouseleave #2181
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
Pushed a new commit which implements both the suggestions in the original description. |
// cursor to 'move'. Otherwise the element is a child ancestor, so set | ||
// it to 'auto' to override the parent's move cursor | ||
const isHoveredElement = element === el | ||
cursor = isHoveredElement ? 'move' : 'auto' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering — do we need to modify the children's cursor values? I feel like if we don't need to show the drag handle, we can just do nothing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, this is a good point actually... This workaround of checking the hover stack is necessary because our deferred leave pattern means the leave handler isn't triggered until the element is removed from the hover stack, so the parent element maintains its cursor style and the child elements need to use auto
to override the cascade.
It might be possible to just not set the cursor style in the deferred leave handler, but in the mouseleave event itself. That would simplify things.
if (cursor) { | ||
element.style.cursor = cursor | ||
} else { | ||
element.style.removeProperty('cursor') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to the above: if we don't modify children's cursor
values, we may not need this removeProperty
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd still need to remove the property for the elements set to move
though right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, I was thinking that the function you added that stores the original value would always reset it anyway, but perhaps not if there was not a cursor set 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working really well. Nice one!
Fix for #2179. This unsets the cursor style when
mouseleave
-ing an overlay element. Previously onmouseleave
the element was specified as thehoveredElement
, which I think would be the element that the cursor was entering after leaving the one we want to reset?Two questions:
auto
on child elements of drag groups?@georgedoescode I've assigned this to you as you'll know the original intention!