[css-display-3] PointerEvent delivered to a pseudo inside a display:contents element yields unexpected results
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 4.9k
- Forks
- 816
- PR merge metrics
- PR metrics pending
Description
There seems to be a gap in the standards algorithm for delivering PointerEvents.
The event properties offsetX and offsetXYshould yield local coordinates from the border-box origin of the closest element which has a box in which to report offsets.
If the original target was a pseudo element inside a display:contents element, offsetX and offsetY are reported as clientX and clientY (Maybe they are pageX and pageY - I haven't tested scroll).
This means processing which utilizes the target and offsetX and offsetY has to do some gymnastics to arrive at the information it wants. It's workaroundable, but should not have to be.
There is a Chromium issue covering this here with some discussion: https://bugs.chromium.org/p/chromium/issues/detail?id=1518093#c11
It can be illustrated in this Codepen: https://codepen.io/Animal-Nige/pen/qBvqxjz
Clicking in the center of the red box logs to the console and reports the event's offsetX and offsetY (which should be around the 50s) as clientX and clientY.
This behaviour is the same in Chromium and Safari, so has probably always been in WebKit. Safari report: https://bugs.webkit.org/show_bug.cgi?id=267815
Firefox also returns unexpected results, but in a different way. Firefox report: https://bugzilla.mozilla.org/show_bug.cgi?id=1875617
So I think the spec must be ambiguous here. The spec needs an extra step when describing how to ascertain the offsetX and offsetY:
"If the element has no box, find the closest parent element which has a box."
Where "closest" is in the sense of the Element#closest method. The closest ancestor.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the CSS Display 3 and Pointer Events algorithms governing offsetX and offsetY, then compare the Chromium, Safari, and Firefox reports linked in the issue. Confirm how pseudo-elements inside display:contents are handled and whether the proposed closest ancestor with a box resolves the ambiguity. Done means the specification clearly defines the offset-reporting step and the Bikeshed draft builds successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css
- Domain
- documentation, web-dev
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100