diff --git a/.changeset/rude-bees-deliver.md b/.changeset/rude-bees-deliver.md new file mode 100644 index 000000000..2e9090895 --- /dev/null +++ b/.changeset/rude-bees-deliver.md @@ -0,0 +1,5 @@ +--- +'@craftjs/core': patch +--- + +Remove node hovered state on mouseleave event diff --git a/packages/core/src/events/DefaultEventHandlers.ts b/packages/core/src/events/DefaultEventHandlers.ts index 4714b149c..95e6ef003 100644 --- a/packages/core/src/events/DefaultEventHandlers.ts +++ b/packages/core/src/events/DefaultEventHandlers.ts @@ -134,8 +134,18 @@ export class DefaultEventHandlers extends CoreEventHandlers< } ); + const unbindMouseleave = this.addCraftEventListener( + el, + 'mouseleave', + (e) => { + e.craft.stopPropagation(); + store.actions.setNodeEvent('hovered', null); + } + ); + return () => { unbindMouseover(); + unbindMouseleave(); }; }, drop: (el: HTMLElement, targetId: NodeId) => {