Closed Bug 2027955 Opened 29 days ago Closed 20 days ago

implicit anchor positioning with pseudo element fail after scrolling

Categories

(Core :: Layout: Positioned, defect, P3)

Firefox 147
defect

Tracking

()

RESOLVED INVALID

People

(Reporter: mic.gallego, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36

Steps to reproduce:

Hello,

I have been unable to re-create a minimal test case, so it might be a set of conditions on my website.

To reproduce the issue:

  1. Open this store: https://stretch-theme-sand.myshopify.com/
  2. Hover the link "learn" in the header to open the mega-menu, and see the overlay shadow.
  3. While keeping your cursor on the link, scroll down the page. At some point, the overlay will disappear.

Actual results:

The overlay is positioned in a ::after pseudo element using this code:

.mega-menu:after {
inset-block: anchor(end) auto;
}

After scrolling for a bit, the overlay disappears on Firefox.

Expected results:

It therefore should follow the scroll and be visible all the time (this is what happens on Chrome and Safari).

Component: Untriaged → CSS Parsing and Computation
Product: Firefox → Core

I think it's a bug in the page? That rule looks like:

@supports (position-anchor: auto) {
  .mega-menu:after {
    inset-block: anchor(end) auto;
    height: 100%;
  }
}

However, they are missing position-anchor: auto itself? This seems to work as they expect:

@supports (position-anchor: auto) {
  .mega-menu:after {
    inset-block: anchor(end) auto;
    height: 100%;
    position-anchor: auto;
  }
}

David, can you sanity-check me? I think this is WAI... We should make sure that there's some test for this or something tho.

Severity: -- → S3
Component: CSS Parsing and Computation → Layout: Positioned
Flags: needinfo?(dshin)
Priority: -- → P3

Are you sure? The spec indicates that pseudo element automatically get the parent as the anchor, so as I understand the spec this should not be needed.

I think it's needed (either that or position-area rather than inset-block: anchor(end) auto, see the discussion in https://github.com/w3c/csswg-drafts/issues/13067.

The spec for position-anchor says that the initial value is normal: https://drafts.csswg.org/css-anchor-position-1/#valdef-position-anchor-normal

If position-area is none, behaves as none. Otherwise, behaves as auto.

Since position-area is none, it behaves as none.

You're correct, using position-area: auto seems to fix it! I think we can close it (although maybe it should be checked why the behavior is inconsistent across browsers here).

Attached file Testcase

Yeah, that is the latest resolution as far as I'm aware. It is a pretty recent resolution, and we in fact don't have normal implemented as of right now, and position-anchor's default value is none.

position-anchor: auto works, and should be the solution for people using anchor() functions instead of position-area, but right now using position-area does not cause us to look for implicit anchors. This is the same on Chrome Canary.

Notably, Safari TP seems to have the default value as auto, which may explain the divergence.

Side note - if someone specified @position-try fallback for these implicit anchor + position-area utilizing positioned elements with position-area: none + anchor() functions they'd lose the implicit anchor, which... could be interesting?

Flags: needinfo?(dshin)
See Also: → 2030351

(Closing this one as INVALID since we are technically closer to spec-compliant here)

Status: UNCONFIRMED → RESOLVED
Closed: 20 days ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: