Closed Bug 1817801 Opened 3 years ago Closed 2 months ago

Background color is overwriting border-color on sticky TH element

Categories

(Core :: Layout: Tables, defect)

Firefox 110
defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: rene.hellenes, Unassigned)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/110.0

Steps to reproduce:

Create a table with a side scroll. in TBody: First cell in a row should be a TH. Give it position sticky, border (eg. gray solid 2px) and a background-color.

The issue is shown in the attached screenshot with most of the settings needed to reproduce

Actual results:

When the background color is added, the border-color disappears. It looks like the border is there, just not visible. It gets visible if you either turn off position sticky or make it a block element.

Expected results:

The desired result is that the border would appear as it does on other elements.

The desired result is achieved in chrome, edge and safari.

Component: Untriaged → Layout: Tables
Product: Firefox → Core

Rene, thanks for the report. Could you possibly provide a simplified testcase that demonstrates the issue? It wasn't entirely clear to me exactly how to set things up.... if you can attach an example HTML file here, or a link to a codepen or similar example, that would be really helpful. Thanks!

Flags: needinfo?(rene.hellenes)
Keywords: testcase-wanted

Sorry for the delayed response. Here you go: a codepen with simplified code

The red border-bottom should go underneath the <th> inside the <tbody> aswell.

Flags: needinfo?(rene.hellenes)

Thanks! So the issue here isn't specific to position:sticky; a similar problem can be reproduced with other properties.

It seems to be the use of a property that causes the th cells to become a new stacking context (like position:sticky) combined with border-collapse:collapse rendering, which results in the borders being painted by the underlying table and then getting obscured by the backgrounds painted by the cells.

A similar problem can be triggered by other properties such as transform or opacity, that also make the cell into a new stacking context. A further-reduced version of the testcase: https://codepen.io/jfkthame/pen/OJoZjZL. I've made the background of the th elements partially opaque here, to highlight how the borders are being painted behind it.

I think what's needed to fix this is to inset the background by half of the border width when border-collapse is in effect, so that they don't overlap.

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true

This no longer reproduces. The codepen from comment 2 (border-collapse table, tbody th { position: sticky; background: lightgrey; border-bottom: 3px solid red }) shows the border missing under the sticky th on the Firefox 111.0 release and painted across the full row on Firefox 158.0a1 (local Linux build, headless screenshots attached, DPR 1 and 2). A contrast page trying position: static/relative, transform, opacity, isolation, will-change, no th background, 1/2/3px borders and border-collapse: separate is green on 158 in every row.

Status: NEW → RESOLVED
Closed: 2 months ago
Keywords: testcase-wanted
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: