import { useEffect } from 'react'

export const useStopPopEvent = (visible?: boolean) => {
  useEffect(() => {
    const handler = (e: Event) => {
      e.stopPropagation()
    }
    document.querySelectorAll('.ant-color-picker input').forEach(input => {
      input.addEventListener('mousedown', handler, true);
      input.addEventListener('click', handler, true);
    });
    return () => {
      document.querySelectorAll('.ant-color-picker input').forEach(input => {
        input.removeEventListener('mousedown', handler, true);
        input.removeEventListener('click', handler, true);
      });
    }
  }, [visible])
}
