kgabryje commented on code in PR #23748: URL: https://github.com/apache/superset/pull/23748#discussion_r1172479130
########## superset-frontend/src/explore/components/controls/DndColumnSelectControl/ColumnSelectPopover.tsx: ########## @@ -117,6 +117,71 @@ const ColumnSelectPopover = ({ ColumnMeta | undefined >(initialSimpleColumn); + const [width, setWidth] = useState(POPOVER_INITIAL_WIDTH); + const [height, setHeight] = useState(POPOVER_INITIAL_HEIGHT); + const [clientX, setClientX] = useState(0); + const [clientY, setClientY] = useState(0); + const [dragStartX, setDragStartX] = useState(0); + const [dragStartY, setDragStartY] = useState(0); + const [dragStartWidth, setDragStartWidth] = useState(width); + const [dragStartHeight, setDragStartHeight] = useState(height); + const [isDragging, setIsDragging] = useState(false); + + const onMouseMove = useCallback((ev: MouseEvent): void => { + ev.preventDefault(); + setClientX(ev.clientX); + setClientY(ev.clientY); + }, []); + + const onMouseUp = useCallback(() => { + setIsDragging(false); + }, []); + + const onDragDown = useCallback((ev: React.MouseEvent): void => { + setDragStartX(ev.clientX); + setDragStartY(ev.clientY); + setIsDragging(true); + }, []); + + useEffect(() => { + if (isDragging) { + document.addEventListener('mousemove', onMouseMove); + } else { + setDragStartWidth(width); + setDragStartHeight(height); + document.removeEventListener('mousemove', onMouseMove); + } + }, [onMouseMove, isDragging]); + + useEffect(() => { + if (isDragging) { + setWidth( Review Comment: I'm wondering if we should have some throttle here - there's going to be a LOT of state updates when user starts dragging -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org