Skip to content

Commit

Permalink
Rich Text: Cleanup excess focusin/focusout listeners (#55382)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Oct 16, 2023
1 parent d9a75d0 commit 7e51b43
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/rich-text/src/component/use-anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ export function useAnchor( { editableContentElement, settings = {} } ) {
editableContentElement.addEventListener( 'focusin', attach );
editableContentElement.addEventListener( 'focusout', detach );

return detach;
return () => {
detach();

editableContentElement.removeEventListener( 'focusin', attach );
editableContentElement.removeEventListener( 'focusout', detach );
};
}, [ editableContentElement, tagName, className ] );

return anchor;
Expand Down

1 comment on commit 7e51b43

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 7e51b43.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6533581690
📝 Reported issues:

Please sign in to comment.