::before pseudo content overwrites select option label text
Categories
(Core :: Layout: Form Controls, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox-esr68 | --- | unaffected |
| firefox-esr78 | --- | fix-optional |
| firefox77 | --- | wontfix |
| firefox78 | --- | wontfix |
| firefox79 | --- | wontfix |
| firefox80 | --- | wontfix |
| firefox85 | --- | wontfix |
| firefox86 | --- | fix-optional |
| firefox87 | --- | fix-optional |
People
(Reporter: zachsteffens, Unassigned)
References
(Depends on 2 open bugs, Regression)
Details
(Keywords: regression)
Attachments
(1 file)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0
Steps to reproduce:
I'm using angularJS to generate a select list with options. The angularJS directive always appends a label to the option so you end up with
<option label="text">text</option>
It doesnt seem like there is a way to omit this label property from the generated html. This poses a problem in FF when you want to use a before pseudo element to prepend text or icons before the option. When you set content on the pseudo before it hides the label that gets displayed.
This issue can be seen demonstrated in a stackoverflow post I created here
https://stackoverflow.com/questions/62271593/dont-include-label-in-ng-options
or in a codepen here
https://codepen.io/zachsteffens/pen/xxZwXax
Some example html is included below.
In this example, I am expecting both first and second to be visible, but in FF, Second is not visible. When The label option is omitted, there is no problem. Is there a CSS workaround to make both the label and the ::before visible?
.optionClass:before{
content:"::before "
}
<select multiple="multiple">
<option class="optionClass">first</option>
<option class="optionClass" label="second" >second</option>
</select>
Actual results:
what shows on FF for windows is
::before first
::before
Expected results:
what should show is
::before first
::before second
Comment 1•5 years ago
|
||
Bugbug thinks this bug should belong to this component, but please revert this change in case of error.
Comment 2•5 years ago
|
||
This is kind of expected given how we ended up implementing <option label> in bug 40545... Except on this case this used to work because on top of the label you also had text.
Updated•5 years ago
|
Updated•5 years ago
|
Comment 3•5 years ago
|
||
And yeah, you can effectively use content: "::before " attr(label); or such from CSS, though that probably shows duplicate labels in other browsers :(
| Reporter | ||
Comment 4•5 years ago
|
||
Your suggestion to use attr(label) in the css content gave me a good idea for a workaround.
I couldn't append the attr(label) to the before content because in my actual implementation I'm using some font awesome icons with different font colors so both the font-face and the color of the label were wrong. So I used a mozilla only css selector and appended the label in the after content. Just need to test to ensure that I dont get double labels anywhere.
@-moz-document url-prefix(){
.optionClass:after{
content: attr(label);
}
}
Updated•5 years ago
|
Comment 5•5 years ago
|
||
Set release status flags based on info from the regressing bug 40545
Comment 6•5 years ago
|
||
(In reply to zachsteffens from comment #4)
I couldn't append the attr(label) to the before content because in my actual implementation I'm using some font awesome icons with different font colors so both the font-face and the color of the label were wrong. So I used a mozilla only css selector and appended the label in the after content. Just need to test to ensure that I dont get double labels anywhere.
Please don't do that, as when we fix this bug then your page will show double labels in Firefox, and may prevent us from actually fixing this...
| Reporter | ||
Comment 7•5 years ago
|
||
I left the codepen with the original code. But I'm working on a enterprise app that needs to be released in the next week. So I put the fix in place there. I'm not super familiar with the timeline of releases of FF so I went ahead with the fix in my code and I'll remove the workaround when the fix is deployed in FF.
Comment 8•5 years ago
|
||
To fix this properly in Firefox we're waiting on bug 1481150. In the meantime we could revert bug 40545's patch and reopen. I guess it's a decision between which use cases we wish to break : |
Comment 9•5 years ago
|
||
(In reply to zachsteffens from comment #7)
I left the codepen with the original code. But I'm working on a enterprise app that needs to be released in the next week. So I put the fix in place there. I'm not super familiar with the timeline of releases of FF so I went ahead with the fix in my code and I'll remove the workaround when the fix is deployed in FF.
Why not removing the label attribute in the second option altogether? If you have the same option text inside it makes zero difference.
| Reporter | ||
Comment 10•5 years ago
|
||
Why not removing the label attribute in the second option altogether? If you have the same option text inside it makes zero difference.
I'm using an AngularJS ng-options directive to generate the options based on a model returned from an API. Ng-options always injects the label into the option element, there's no simple way to remove it. I could override a few hundred lines of angularJS by creating a custom ng-options directive, or I could include a few lines of css to get the same result.
Comment 11•5 years ago
|
||
Le sad, why would they do that?
Comment 12•5 years ago
|
||
We still use the ::before machinery, but we prevent author changes to
it from removing the label.
Not quite sure how I feel about this :-/
Updated•5 years ago
|
Updated•5 years ago
|
Comment 13•5 years ago
|
||
Hey Emilio, is this just stalled since we don't have a great solution still?
Comment 14•5 years ago
|
||
Pretty much, I'm not a fan of this solution. The proper fix needs a lot more work.
Comment 15•4 years ago
|
||
Hi! I was able to reproduce this issue on latest Nightly 87.0a1, Beta 86.0b5, ESR 78.7.0, and Release 85.0 on Windows 10, Ubuntu 20. and macOS 10.15.
I'll change flags accordingly.
Updated•4 years ago
|
Updated•4 years ago
|
Description
•