rusackas opened a new pull request, #43498:
URL: https://github.com/apache/superset/pull/43498

   ### SUMMARY
   Reported: in the dataset editor's Calculated columns tab (and any other 
draggable modal), trying to click-and-drag to select text anywhere in the modal 
instead drags the whole modal window.
   
   Root cause: whether the draggable modal could actually be dragged was 
tracked with a `dragDisabled` boolean, toggled only by 
`mouseover`/`mouseout`/`focus`/`blur` on the title bar's `.draggable-trigger` 
element. That element was defined as an inline function component inside the 
modal's render body, so React gives it a fresh identity on every render — 
meaning any unrelated state change while the cursor happened to be resting over 
the title (e.g. typing into any field elsewhere in the modal, which is 
extremely common) force-unmounts and remounts it, without a real `mouseout` 
ever firing on the old node. `dragDisabled` gets stuck at `false` from that 
point on, and any later click-and-drag anywhere in the modal — including inside 
a text input, where the user expects to select text — gets picked up as a drag 
of the whole modal.
   
   In practice this is very easy to trigger: opening a modal at all usually 
means the cursor passes over the title on its way in, and virtually any 
keystroke afterward can desync the flag.
   
   Fixed by replacing the hover-tracked boolean with `react-draggable`'s own 
`handle` prop, pointed at `.draggable-trigger`. `handle` is checked against the 
actual event target live, at drag-start time, so there's no separate state to 
desync from what the DOM is actually doing. Also removes ~15 lines of 
hand-rolled hover tracking that this makes unnecessary.
   
   ### TESTING INSTRUCTIONS
   `npx jest packages/superset-ui-core/src/components/Modal` — added 
`Modal.test.tsx` covering: dragging from the title bar still works, dragging 
inside modal content doesn't move the modal, the reported regression scenario 
specifically (hover the title, an unrelated re-render happens, then drag inside 
a text field — this fails against the pre-fix code and passes with the fix), 
and that non-draggable modals never render a drag handle at all.
   
   Manually: open Edit Dataset → Calculated columns → try to click-and-drag to 
select text in the Column field. Selects text normally instead of dragging the 
modal.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to