Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

621 B
Raw Blame
/**
 * Returns true when an event target is inside the code-block language picker.
 *
 * `MouseEvent.relatedTarget` is typed as `EventTarget | null` and at runtime
 * can be a non-Element node (e.g. a Text node when the pointer moves between
 * text runs) or `null`. Calling `.closest()` on either throws, so the
 * `instanceof Element` guard is load-bearing for the mouseleave handlers in
 * the comment and task-description editors.
 */
export function isInCodeBlockLanguagePicker(target: EventTarget | null) {
  return (
    target instanceof Element &&
    target.closest(".kaneo-codeblock-language") !== null
  );
}