Skip to content

Fix Clipboard Fallback by Checking textArea.select Return Value - #8880

Open
tmdeveloper007 wants to merge 1 commit into
JhaSourav07:mainfrom
tmdeveloper007:fix/8848-clipboard-select-return-value
Open

Fix Clipboard Fallback by Checking textArea.select Return Value#8880
tmdeveloper007 wants to merge 1 commit into
JhaSourav07:mainfrom
tmdeveloper007:fix/8848-clipboard-select-return-value

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Summary of What Has Been Done

Modified fallbackCopyToClipboard to check the return value of textArea.select(). Returns false immediately if selection fails.

Changes Made

  • utils/clipboard.ts: Check textArea.select() return value; return false early if selection fails

Impact it Made

  • Provides clearer failure signaling when copy operation cannot proceed
  • Avoids unnecessary execCommand calls when selection is not possible

Closes #8848

Note: Please assign this PR to the tmdeveloper007 account.

@retenta-bot

retenta-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

This pull request improves the clipboard fallback handling by checking the return value of textArea.select(). This change provides clearer failure signaling when the copy operation cannot proceed and avoids unnecessary calls to document.execCommand('copy'). This approach aligns with previous decisions made to enhance performance and reliability in clipboard operations. Thank you for your contribution!

@retenta-bot retenta-bot Bot changed the title fix : checked return value of textArea.select in clipboard fallback Fix Clipboard Fallback by Checking textArea.select Return Value Aug 5, 2026
@Aamod007 Aamod007 added level:beginner Small changes Usually isolated fixes or simple UI/text updates. type:bug Something isn't working as expected mentor:Aamod007 labels Aug 6, 2026

@Aamod007 Aamod007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate you looking into improving the clipboard fallback in \utils/clipboard.ts. However, I have a concern with the changes: the .select()\ method on \HTMLTextAreaElement\ returns \�oid\ (undefined), not a boolean indicating success. Because of this, \const selected = textArea.select(); if (!selected) return false;\ will always evaluate to false and the function will never reach \execCommand('copy'). Please double-check the MDN documentation for \HTMLTextAreaElement.select()\ and revise this approach. I'll have to request changes for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:beginner Small changes Usually isolated fixes or simple UI/text updates. mentor:Aamod007 type:bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix : check return value of textArea.select in clipboard fallback

2 participants