Refactor native select caret styles, fixes #571 and #572 #594
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.
For styling a native
<select>
, the story goes:::after
on a<select>
.::after
on a<label>
containing the select because it won't appear for selects outside of a label.background-color
+mask
on a<select>
to get the right shape and color of the caret since...well, the select itself will be masked.So, in a live discussion of #571, we chose to use the browser's default caret rather than trying to replace it with our own. As it turns out...
We can't do that because each browser's default select styling creates inconsistencies, but most of all...Safari.
❌ Fail: Using the browser's default caret
Removing

appearance: none
to use the browser's default caret yielded these results:Firefox (close!)
Chrome and Edge (they add space around the selected value that we can't seem to target)

Safari (straight-up doesn't care)

✅ Pass: Using
background-image
withbackground-blend-mode
So, I ended up taking the approach of keeping
appearance: none
and using abackground-image
withbackground-blend-mode
.The results are not exact, but they are passable. Here are some examples:




Default theme:
Awesome theme:




The worst offenders are selects in the Premium theme, where
background-blend-mode
is less effective because the theme sets--wa-form-control-background-color: transparent
.A filled select in dark mode is not especially great:

An outlined select in light mode is meh:

There may be a closer match, but I've exceeded the allotment of time I'd like to spend mixing and matching blend modes for now.