michael-s-molina opened a new pull request, #37550:
URL: https://github.com/apache/superset/pull/37550

   ### SUMMARY
   
   This PR fixes a bug in SQL Lab where text selection using keyboard shortcuts 
(e.g., `Cmd+Shift+Arrow`) would break after certain operations like selecting 
text, deleting it, and then undoing the deletion.
   
   **Root Cause:**
   The `AceEditorProvider` component registered event listeners for 
`changeCursor` and `changeSelection` events during editor initialization. These 
listeners captured callback references at registration time, creating stale 
closures when the parent component re-rendered with new callback functions.
   
   **Fix:**
   - Added refs (`onCursorPositionChangeRef` and `onSelectionChangeRef`) to 
store the latest callback references
   - Event listeners now access callbacks through refs, ensuring they always 
use the most recent function
   - Memoized the `handle` object with `useMemo` to prevent unnecessary 
recreation on every render
   - Added a guard ref (`onReadyCalledRef`) to ensure `onReady` is only called 
once
   
   **Additional Fix:**
   - Updated `EditorWrapper` to properly clear `selectedText` in Redux when 
selection becomes empty (cursor moved without selecting)
   
   ### TESTING INSTRUCTIONS
   
   1. Open SQL Lab and create a new tab
   2. Select the default "SELECT..." text using `Cmd+Shift+Arrow Right`
   3. Delete the selected text
   4. Press `Cmd+Z` to undo
   5. Try to select the text again using `Cmd+Shift+Arrow Right`
   6. Verify the text is properly selected and highlighted
   7. Press Enter to move text to line 2, then use Arrow Down to move cursor
   8. Verify the cursor moves correctly to line 2
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] 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