Skip to content

Conversation

AlexV525
Copy link
Member

@AlexV525 AlexV525 commented Oct 12, 2025

Fixes #8572

The request sets the foreground color and hover color consistently across all circumstances.

Before After
Dark image image
Light image image
Light with Light Header image image
High Contrast image image

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

@AlexV525 AlexV525 added the 🤖 AI-assisted For PRs with significant code generated by AI label Oct 12, 2025
@AlexV525 AlexV525 marked this pull request as ready for review October 12, 2025 15:00
@AlexV525 AlexV525 requested review from helin24 and jwren October 12, 2025 15:00
Copy link
Member

@helin24 helin24 left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this! The screenshots look great. I'm hoping we can extract some additional info from AI to make sure we can easily fix this if there are platform changes in the future.

g2.setColor(JBUI.CurrentTheme.ActionButton.hoverBackground());
// Use MainToolbar hover background to adapt to the toolbar theme (e.g., dark header with light theme)
final JBColor hoverColor = JBColor.namedColor(
"MainToolbar.Icon.hoverBackground",
Copy link
Member

Choose a reason for hiding this comment

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

I'm nervous about having plain strings to identify colors in these spots - do you (or AI) know how we can find these key names in case they change in the future? What happens if the key is not findable? I wonder if we could instead pull out smaller functions like getHoverColor and add unit tests to make sure we're able to get a reasonable color?

Separately, if there are IJ platform constants that we could use here instead, that would be ideal. If not, then let's at least pull out as our own constants in this class.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm nervous about having plain strings to identify colors in these spots - do you (or AI) know how we can find these key names in case they change in the future?

It seems to find keys from https://github.com/JetBrains/intellij-community/blob/idea/252.26830.84/platform/platform-resources/src/themes/HighContrast.theme.json. I didn't see a clear documentation that declares color properties. But I've added some descriptions to explain the behavior clearly.

What happens if the key is not findable?

It will fall back to a default color value.

I wonder if we could instead pull out smaller functions like getHoverColor and add unit tests to make sure we're able to get a reasonable color?

I've added some unit tests.

Separately, if there are IJ platform constants that we could use here instead, that would be ideal. If not, then let's at least pull out as our own constants in this class.

Unfortunately, from my understanding and during my code, I found no accurate constant members for these colors.

Copy link
Member

@helin24 helin24 left a comment

Choose a reason for hiding this comment

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

Thanks for the edits! My remaining question is whether we can avoid using reflection in the tests by changing to non-static methods.

* Theme property key for the main toolbar foreground color.
* This key is used to retrieve the appropriate text color for toolbar components,
* ensuring proper visibility in all theme configurations (e.g., light theme with dark header).
* If this key is not found in the current theme, falls back to the standard label foreground color.
Copy link
Member

Choose a reason for hiding this comment

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

Let's take out this last line about the fallback as this is mentioned in the method that uses the key and isn't relevant to the key delcaration

* Theme property key for the main toolbar icon hover background color.
* This key is used to retrieve the appropriate hover background color for toolbar icon buttons,
* ensuring consistency with other toolbar actions in all theme configurations.
* If this key is not found in the current theme, falls back to the standard action button hover background.
Copy link
Member

Choose a reason for hiding this comment

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

Take out this fallback comment as well

}

/**
* Invokes the private static getToolbarHoverBackgroundColor method via reflection.
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary to make these static methods? Could this test file be simpler if we made them non-static methods?

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

Labels

🤖 AI-assisted For PRs with significant code generated by AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Name of the selected device is not visible in toolbar

2 participants