Skip to content

Conversation

@anshuksi282-ksolves
Copy link
Contributor

Fix text selection contrast in Airflow UI logs and code views

Issue: #56449

Context and Problem
Following the v3.1.0 theming overhaul, Airflow adopted Chakra UI semantic tokens and a Tailwind-inspired color palette. However, explicit ::selection pseudo-element styling was omitted. As a result, browsers defaulted to low-contrast selection highlights that blend into the log and code background, making user text selections nearly invisible.

Impact
Users cannot reliably select and copy text from logs or code blocks, hindering troubleshooting, debugging, and overall accessibility.

Solution

Added global ::selection, ::-moz-selection, and ::-webkit-selection rules in the Chakra theme configuration (src/theme.ts) under globalCss, enforcing a clear blue highlight (blue.500 in light mode, blue.300 in dark mode).

Created a dedicated CSS file (src/assets/selection.css) with selection rules for pre, code, .log-viewer, and elements with data-testid*="log", ensuring consistent blue highlighting in log and code areas.

Imported selection.css in the application entry point (src/main.tsx) so that styles load early.

These changes restore high-contrast text selection, comply with WCAG AA contrast requirements, and improve user experience when copying or inspecting logs and code.

Screencast.from.2025-10-07.17-14-37.webm

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@bbovenzi
Copy link
Contributor

bbovenzi commented Oct 8, 2025

Oh let's not mix in css files into the Chakra React components.

@RoyLee1224
Copy link
Contributor

I think we already have a PR for text selection here #56379

Copy link
Member

@pierrejeambrun pierrejeambrun 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 PR.

pre ::selection,
code ::selection,
.log-viewer ::selection,
[data-testid*="log"] ::selection {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should rely on data-testid for production code. We can set a real 'id' or use another mechanism to identify those elements.

The reason for that is because I wouldn't expect to break the code by modifying test ids. I would expect only tests to fail.

Comment on lines +38 to +65

// Fix for text selection contrast issue #56449

globalCss: {

"::selection": {

backgroundColor: "blue.500",

color: "white",

textShadow: "none",

},

"::-moz-selection": {

backgroundColor: "blue.500",

color: "white",

textShadow: "none",

},

"::-webkit-selection": {

backgroundColor: "blue.500",
Copy link
Member

Choose a reason for hiding this comment

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

Is this piece necessary since we now have a separate css file ?

* under the License.
*/


Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

}

::-moz-selection {
background-color: #3182ce !important;
Copy link
Member

Choose a reason for hiding this comment

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

Do we need all those !important we tend to try to avoid them.

@pierrejeambrun
Copy link
Member

I'm more in favor of https://github.com/apache/airflow/pull/56379/files. Not sure what this one brings now that it's merged.

@bbovenzi
Copy link
Contributor

I agree. Let's close this one.

@bbovenzi bbovenzi closed this Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers area:UI Related to UI/UX. For Frontend Developers. provider:fab

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants