Repository: element-plus/element-plus
File: packages/components/table/src/table-header/event-helper.ts (TypeScript)

Code before:
      document.addEventListener('mousemove', handleMouseMove)
      document.addEventListener('mouseup', handleMouseUp)
    }
  }

  const handleMouseMove = (event: MouseEvent, column: TableColumnCtx<T>) => {
    if (!props.border || (column.children && column.children.length > 0)) return
    const el = event.target as HTMLElement
    const target = isElement(el) ? el.closest('th') : null
    if (!target) {
      return
    }

    const isSortable = hasClass(target, 'is-sortable')

    if (isSortable) {
      const cursor = dragging.value ? 'col-resize' : ''
      target.style.cursor = cursor

      const caret = target.querySelector<HTMLElement>('.caret-wrapper')
      if (caret) {
        caret.style.cursor = cursor
      }
    }

    if (!column?.resizable || dragging.value) {
      draggingColumn.value = null
      return
    }

    const rect = target.getBoundingClientRect()
    const isLastTh = target.parentNode?.lastElementChild === target
    const allowDrag = props.allowDragLastColumn || !isLastTh
    const isResizeHandleActive =
      rect.width > 12 && rect.right - event.clientX < 8 && allowDrag
    const cursor = isResizeHandleActive ? 'col-resize' : ''

    document.body.style.cursor = cursor
    draggingColumn.value = isResizeHandleActive ? (column as any) : null
    if (isSortable) {
      target.style.cursor = cursor
    }
  }

  const handleMouseOut = () => {
    if (!isClient || dragging.value) return
    document.body.style.cursor = ''
  }
  const toggleOrder = ({ order, sortOrders }: TableColumnCtx<T>) => {
    if ((order as string) === '') return sortOrders[0]
    const index = sortOrders.indexOf(order || null)

Review comment (suggestion):
```suggestion
    if (!column.resizable || dragging.value) {
```

Code after:
      document.addEventListener('mousemove', handleMouseMove)
      document.addEventListener('mouseup', handleMouseUp)
    }
  }

  const handleMouseMove = (event: MouseEvent, column: TableColumnCtx<T>) => {
    if (!props.border || (column.children && column.children.length > 0)) return
    const el = event.target as HTMLElement
    const target = isElement(el) ? el.closest('th') : null
    if (!target) {
      return
    }

    const isSortable = hasClass(target, 'is-sortable')

    if (isSortable) {
      const cursor = dragging.value ? 'col-resize' : ''
      target.style.cursor = cursor

      const caret = target.querySelector<HTMLElement>('.caret-wrapper')
      if (caret) {
        caret.style.cursor = cursor
      }
    }

    if (!column.resizable || dragging.value) {
      draggingColumn.value = null
      return
    }

    const rect = target.getBoundingClientRect()
    const isLastTh = target.parentNode?.lastElementChild === target
    const allowDrag = props.allowDragLastColumn || !isLastTh
    const isResizeHandleActive =
      rect.width > 12 && rect.right - event.clientX < 8 && allowDrag
    const cursor = isResizeHandleActive ? 'col-resize' : ''

    document.body.style.cursor = cursor
    draggingColumn.value = isResizeHandleActive ? (column as any) : null
    if (isSortable) {
      target.style.cursor = cursor
    }
  }

  const handleMouseOut = () => {
    if (!isClient || dragging.value) return
    document.body.style.cursor = ''
  }
  const toggleOrder = ({ order, sortOrders }: TableColumnCtx<T>) => {
    if ((order as string) === '') return sortOrders[0]
    const index = sortOrders.indexOf(order || null)