Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure consistent opacity for disabled form controls in all browsers #14991

Closed
wants to merge 3 commits into from

Conversation

adamwathan
Copy link
Member

We noticed that in Chrome, disabled <select> elements were being rendered at 70% opacity, but were being rendered at 100% opacity in Firefox and Safari. After some research, we learned that all form controls in all browsers are rendered at a lower opacity when disabled if you don't include our other Preflight styles, but some of the other normalizations we do in Preflight (specifically stuff around borders) causes each browser to abandon their default/native control styles, and only Chrome persists the user-agent opacity setting it was using for the untouched native control.

This PR just sets the opacity for all disabled elements to 1 so that there are no surprises and you can style your disabled elements however you want. This is something we ran into on Catalyst, and had to add disabled:opacity-100 to our select controls to avoid since we had our own custom styles for them.

@adamwathan adamwathan requested a review from a team as a code owner November 13, 2024 16:03
Copy link
Contributor

@thecrypticace thecrypticace left a comment

Choose a reason for hiding this comment

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

Noticed one thing that looks broken

@@ -475,6 +475,14 @@ exports[`\`@import 'tailwindcss'\` is replaced with the generated CSS 1`] = `
color: inherit;
}

::file-selector-button:where() {
Copy link
Contributor

@thecrypticace thecrypticace Nov 13, 2024

Choose a reason for hiding this comment

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

This is definitely wrong. Maybe this is a lightningcss bug? Looks like it works in Lightning's playground so we should probably work on upgrading.

Maybe split the selector in preflight temporarily to work around it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yeah good catch. Noticing other stuff that's kinda in this same category of fixes, like input elements get a different background color when disabled too. Not sure how far to go with this stuff, tricky.

@philipp-spiess
Copy link
Member

The changes in this PR are included in #15036

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.

3 participants