Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Conversation

hawkticehurst
Copy link
Member

Link to relevant issue

This pull request resolves #277 and #278

Description of changes

Add the listActiveSelectionForeground color token to all slotted content in data grid cells. This resolves a bug in VS Code light themes where the color of slotted elements in data grid cells did not have high enough contrast with the background when focused/active.

Before

image
image

After

Screen Shot 2022-03-01 at 5 16 43 PM

Screen Shot 2022-03-01 at 5 16 50 PM

@hawkticehurst hawkticehurst linked an issue Mar 2, 2022 that may be closed by this pull request
@atanasster
Copy link

Thank you!

Copy link
Collaborator

@daviddossett daviddossett left a comment

Choose a reason for hiding this comment

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

Perfect, thank you 🙏

:host(:${focusVisible}) ::slotted(*),
:host(:focus) ::slotted(*),
:host(:active) ::slotted(*) {
color: ${listActiveSelectionForeground} !important;
Copy link
Collaborator

@daviddossett daviddossett Mar 2, 2022

Choose a reason for hiding this comment

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

All of the pseudos!

Out of curiosity, why was !important needed here?

Copy link
Member Author

Choose a reason for hiding this comment

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

The !important is needed because I discovered that (for whatever reason) a lot of base HTML tags (i.e. a, code, etc.) are styled within a style tag that lives directly within the webview HTML document.

As a result, without the !important the styles within the style tag will have higher specificity than styles defined in the code above and get overridden.

I think this is also the reason that I had such a ridiculously challenging time trying to fix these bugs back in November because I didn't catch that these base tags were being styled directly in the HTML document and needed an !important tag to be overridden.

Copy link
Member Author

Choose a reason for hiding this comment

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

For the purposes of posterity, here are some reference screenshots to what I'm talking about in case we ever run into this again.

Note how the selector for a, a code has higher specificity than the styles defined by the data-grid-cell. It's only by applying !important that we can override these higher priority styles.

Screen Shot 2022-03-02 at 2 34 43 PM

By clicking the <style> link in the top-right corner of the styling block in the above image, the DevTools inspector will take us to the spot where these styles are applied and here we can see that it is an inline style tag that lives in the head of the webview iframe.

Screen Shot 2022-03-02 at 2 41 05 PM

@hawkticehurst
Copy link
Member Author

hawkticehurst commented Mar 2, 2022

Thank you!

You're welcome @atanasster! Sorry it took so long 😅

@hawkticehurst hawkticehurst merged commit ce77e82 into microsoft:main Mar 2, 2022
@hawkticehurst hawkticehurst deleted the data-grid-cell-code branch March 2, 2022 22:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

data-grid: styling of selected cell->code data-grid: styling of selected cell->anchor

3 participants