Skip to content

Normalize non-text selection ranges in gridCore getSelectionRange#34327

Closed
nightskylark with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-review-comment-34325-3590182779
Closed

Normalize non-text selection ranges in gridCore getSelectionRange#34327
nightskylark with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-review-comment-34325-3590182779

Conversation

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

This addresses the review feedback on PR comment r3590182779: getSelectionRange declared numeric SelectionRange values but could return undefined for non-selectable active elements. The change keeps the contract sound by normalizing unsupported selection values.

  • Problem addressed

    • getSelectionRange could return { selectionStart: undefined, selectionEnd: undefined } when the focused element did not support text selection APIs.
    • Downstream logic already treats negative indices as “no selection”; returning undefined violated the expected numeric shape.
  • Targeted code change

    • Updated /packages/devextreme/js/__internal/grids/grid_core/m_utils.ts in getSelectionRange(...).
    • selectionStart / selectionEnd are now normalized to -1 when values are not numeric.
  • Behavioral impact

    • The function now consistently returns numeric selection bounds for supported and unsupported elements.
    • Existing guards using >= 0 continue to work without shape mismatches.
return {
  selectionStart: isNumeric(focusedElement.selectionStart) ? focusedElement.selectionStart : -1,
  selectionEnd: isNumeric(focusedElement.selectionEnd) ? focusedElement.selectionEnd : -1,
};

Copilot AI changed the title [WIP] Fix code as per review comment on PR 34325 Normalize non-text selection ranges in gridCore getSelectionRange Jul 15, 2026
Copilot AI requested a review from nightskylark July 15, 2026 19:46
@nightskylark
nightskylark deleted the copilot/fix-review-comment-34325-3590182779 branch July 15, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants