Revert "Don't use color-mix(…) on currentColor (#17247)" and work around Preflight crash#17306
Merged
philipp-spiess merged 1 commit intomainfrom Mar 20, 2025
Merged
Revert "Don't use color-mix(…) on currentColor (#17247)" and work around Preflight crash#17306philipp-spiess merged 1 commit intomainfrom
color-mix(…) on currentColor (#17247)" and work around Preflight crash#17306philipp-spiess merged 1 commit intomainfrom
Conversation
81d4173 to 7e1bc66 Compare color-mix(…) on currentColor (#17247)"color-mix(…) on currentColor (#17247)" and work around Preflight crash … around Preflight crash This reverts commit d6d913e.
7e1bc66 to e5c0b50 Compare RobinMalfait approved these changes Mar 20, 2025
tongrow pushed a commit to tongrow/tailwind-normalize that referenced this pull request Jun 2, 2025
…" and work around Preflight crash (tailwindlabs#17306) Closes tailwindlabs#17194. This reverts commit d6d913e. The initial fix does breaks older versions of Chrome (where text won't render with a color for the placeholder at all anymore) and the usage of the _relative colors_ features also means it'll require a much newer version of Safari/Firefox/Chrome to work correctly. The implementation was also wrong as it always set alpha to the specific percent instead of applying it additively (note that this can be fixed with `calc(alpha * opacity)` though). Instead we decided to fix this by adding a `@supports` query to Preflight that only targets browsers that aren't affected by the crash. We currently use the following workaround: ```css /* Set the default placeholder color to a semi-transparent version of the current text color in browsers that do not crash when using `color-mix(…)` with `currentColor`. (tailwindlabs#17194) */ @supports (not (-webkit-appearance: -apple-pay-button)) /* Not Safari */ or (contain-intrinsic-size: 1px) /* Safari 17+ */ { ::placeholder { color: color-mix(in oklab, currentColor 50%, transparent); } } ``` ## Test plan When testing the `color-mix(currentColor)` vs `oklab(from currentColor …)` we created the following support matrix. I'm extending it with _our fix_ which is the fix ended up using: | Browser | Version | `color-mix(… currentColor …)` | `oklab(from currentColor …)` | `@supports { color-mix(…) }` | | ------- | ------- | ----------------------------- | ---------------------------- | ------- | | Chrome | 111 | ❌ | ❌ | ❌ | | Chrome | 116 | ✅ | ❌ | ✅ | | Chrome | 131+ | ✅ | ✅ | ✅ | | Safari | 16.4 | 💥 | ❌ | ❌ | | Safari | 16.6+ | ✅ | ❌ | ❌ | | Safari | 18+ | ✅ | ✅ | ✅ | | Firefox | 128 | ✅ | ❌ | ✅ | | Firefox | 133 | ✅ | ✅ | ✅ | Note that on Safari 16, this change makes it so that the browser does not crash yet it still won't work either. That's because now the browser will fall back to the default placeholder color instead. We used the following play to test the fix: https://play.tailwindcss.com/RF1RYbZLKY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #17194.
This reverts commit d6d913e.
The initial fix does breaks older versions of Chrome (where text won't render with a color for the placeholder at all anymore) and the usage of the relative colors features also means it'll require a much newer version of Safari/Firefox/Chrome to work correctly. The implementation was also wrong as it always set alpha to the specific percent instead of applying it additively (note that this can be fixed with
calc(alpha * opacity)though).Instead we decided to fix this by adding a
@supportsquery to Preflight that only targets browsers that aren't affected by the crash. We currently use the following workaround:Test plan
When testing the
color-mix(currentColor)vsoklab(from currentColor …)we created the following support matrix. I'm extending it with our fix which is the fix ended up using:color-mix(… currentColor …)oklab(from currentColor …)@supports { color-mix(…) }Note that on Safari 16, this change makes it so that the browser does not crash yet it still won't work either. That's because now the browser will fall back to the default placeholder color instead. We used the following play to test the fix: https://play.tailwindcss.com/RF1RYbZLKY