fix: Remove console error and improve copy-code utility cross-browser⦠#496
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request: Fix Copy-Code Console Error
π Description
This PR fixes the console error in the copy-code utility that was generating unnecessary noise when no code content was found to copy. The changes improve cross-browser compatibility and provide user-friendly visual feedback instead of developer-focused console errors.
Key Improvements:
Fixes console noise when copy operation fails and ensures copy functionality works across all browsers including Firefox, Safari, and older browser versions.
π Related Issue
Fixes #493 - Copy-Code Error Handling
π Type of Change
π· Visual Changes
Before: Console error appears when copy fails
After: Visual button feedback (green "Copied!" or red "Failed") with no console errors
π§ͺ Testing Performed
π± Browser Compatibility
π₯οΈ Responsive Design
β Test Cases
βΏ Accessibility
π PR Checklist
π Additional Notes
This fix addresses the user experience issue where developers would see console errors during normal website usage. The new implementation:
The changes are minimal and focused, ensuring no breaking changes to existing functionality while significantly improving the user experience across all browsers and devices.
π§ Technical Details
Before (Issues):
After (Fixed):
Cross-Browser Compatibility:
navigator.clipboard.writeText()document.execCommand('copy')setSelectionRange()for better text selectionπ Reviewer Resources
Thank you for contributing to the Sugar Labs website! π