Skip to content

[Monaco Editor] Fix text selection not visible in High Contrast Mode#14

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-13
Draft

[Monaco Editor] Fix text selection not visible in High Contrast Mode#14
Copilot wants to merge 2 commits intomainfrom
copilot/fix-13

Conversation

Copy link

Copilot AI commented May 23, 2025

Issue

In High Contrast Mode, text selection in Monaco Editor is not visible across multiple PowerToys components:

  • Peek
  • Registry Preview
  • File Explorer Addons

This makes the editor difficult to use for users with accessibility needs who depend on High Contrast Mode.

Solution

Added CSS styles that specifically handle text selection in High Contrast Mode to:

  1. The main Monaco template (src/Monaco/index.html)
  2. The Registry Preview implementation (src/modules/registrypreview/RegistryPreviewUILib/Assets/RegistryPreview/index.html)

The implementation uses:

  • The @media (forced-colors: active) media query to detect when the system is in High Contrast Mode
  • System colors Highlight and HighlightText to ensure proper contrast in all High Contrast themes
  • The !important directive to override default Monaco styles
/* Fix for text selection in High Contrast Mode */
@media (forced-colors: active) {
    .monaco-editor .focused .selected-text {
        background-color: Highlight !important;
        color: HighlightText !important;
    }
    .monaco-editor .selected-text {
        background-color: Highlight !important;
        color: HighlightText !important;
    }
}

These changes ensure that text selection is visible regardless of the High Contrast theme applied by the user.

Fixes #13.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: lei9444 <39758135+lei9444@users.noreply.github.com>
Copilot AI changed the title [WIP] [Peek, Registry Preview, File Explorer Addons] Monaco Editor: Text selection not visible in High Contrast Mode [Monaco Editor] Fix text selection not visible in High Contrast Mode May 23, 2025
Copilot AI requested a review from lei9444 May 23, 2025 13:21
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.

[Peek, Registry Preview, File Explorer Addons] Monaco Editor: Text selection not visible in High Contrast Mode

2 participants