Skip to content

Commit

Permalink
feat: remove node hovered state on mouseleave event (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
giliamverheide authored Oct 22, 2023
1 parent b5df8ce commit e8681d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-bees-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@craftjs/core': patch
---

Remove node hovered state on mouseleave event
10 changes: 10 additions & 0 deletions packages/core/src/events/DefaultEventHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,18 @@ export class DefaultEventHandlers<O = {}> extends CoreEventHandlers<
}
);

const unbindMouseleave = this.addCraftEventListener(

This comment has been minimized.

Copy link
@LengYXin

LengYXin Nov 1, 2023

This patch causes blinking when the mouse is moved over the hover toolbar @giliamverheide

This comment has been minimized.

Copy link
@prevwong

prevwong Nov 2, 2023

Owner

Thanks for the catch @LengYXin.

I can see both behaviours being useful for different page editors. Perhaps, we can provide this as an option, so for those who would like the new behaviour, they could specify it by passing an option to the DefaultEventHandlers:

<Editor handlers={store => new DefaultEventHandler(store, { 
  removeHoverStateOnMouseleave: true
})} />

cc: @giliamverheide

This comment has been minimized.

Copy link
@LengYXin

LengYXin Nov 14, 2023

The actual bounce rate is faster than git. gif frame rate is limited
iShot_2023-11-14_13 43 43

el,
'mouseleave',
(e) => {
e.craft.stopPropagation();
store.actions.setNodeEvent('hovered', null);
}
);

return () => {
unbindMouseover();
unbindMouseleave();
};
},
drop: (el: HTMLElement, targetId: NodeId) => {
Expand Down

0 comments on commit e8681d2

Please sign in to comment.