Re: [csswg-drafts] [cssom-view] Consider adding Element.scrollParent (#1522)

The CSS Working Group just discussed `[cssom-view] Consider adding Element.scrollParent`, and agreed to the following:

* `RESOLVED: add scrollParent to the spec`

<details><summary>The full IRC log of that discussion</summary>
&lt;JoshT> flackr: We've had a bunch of other APIs to expose the parent and offset parent, but devs have to do a lot of querying to find nearest scroll container<br>
&lt;emilio> q+<br>
&lt;JoshT> ... resolution proposed is to expose it. scrollParent. the nearest container that's a scroll container<br>
&lt;TabAtkins> q+<br>
&lt;iank_> q+<br>
&lt;astearns> ack schenney<br>
&lt;astearns> ack emilio<br>
&lt;JoshT> emilio: Just to confirm, we're talking about the scroll container you scroll relative to<br>
&lt;JoshT> ... for stuff like fixpos, it should return null<br>
&lt;TabAtkins> yes, .scrollingElement I think is right<br>
&lt;JoshT> ... I'm assuming for the root scroller, we return ... there are some complexities there. we could return document.scrollingElement?<br>
&lt;JoshT> ... I guess ?? it sounds good<br>
&lt;astearns> ack TabAtkins<br>
&lt;emilio> s/??/modulo details<br>
&lt;JoshT> TabAtkins: bramus suggested in the thread calling it scrollingParent<br>
&lt;emilio> s/we return .../we return the scrollingElement (in quirks mode that's the body)<br>
&lt;astearns> ack iank_<br>
&lt;JoshT> ... I'm not sure if we have other scroll APIs that suggest we should stick with 'scroll'<br>
&lt;TabAtkins> to be consistent with .scrollingElement<br>
&lt;JoshT> iank_: just to check, flackr, this will walk up the containing block chain?<br>
&lt;kizu> q+<br>
&lt;smfr> q+<br>
&lt;JoshT> ... so if abspos skips, it can skip a scroller and make sure it returns the next one<br>
&lt;astearns> ack kizu<br>
&lt;emilio> q+<br>
&lt;JoshT> kizu: I wanted to mention how we handle elements with ??? auto, scroll, where there an element not overflowing<br>
&lt;JoshT> ... and cases where it clips something, so it is inside content but not scrollable by usual means<br>
&lt;JoshT> ... this is what we currently on our app do. we go up the chain, looking for scrollable containers (compared to offsetHeight with actual height) and go further if it's not currently scrollable<br>
&lt;JoshT> ... so if it will not work as expected, we will need to mention this and propose what it should do in this case<br>
&lt;JoshT> flackr: I disagree we should make it work this way. e.g. stickypos is offset to the nearest scroll container.<br>
&lt;TabAtkins> +1 to flackr's point<br>
&lt;iank_> +1<br>
&lt;JoshT> ... I think it should follow the spec definition of a scroll container<br>
&lt;smfr> q-<br>
&lt;oriol> +1. overflow:hidden can scroll by script, no scrollbar needed<br>
&lt;emilio> +1<br>
&lt;JoshT> ... if a dev wants to find the thing that actually scrolls, they will still need additional logic<br>
&lt;JoshT> astearns: you were saying the spec needs an example of how to do it this way?<br>
&lt;JoshT> kizu: authors will want to be able to do this. there is also a precident for us to have state queries to ask if an element is scrollable right now<br>
&lt;JoshT> ... this is what authors want now. not theoretical scrollability<br>
&lt;JoshT> ... it will be already accessible, but maybe we could make it better<br>
&lt;iank_> It depends a lot on the usecase for what you want to do.<br>
&lt;JoshT> flackr: this at least makes it easier to get what you're asking for<br>
&lt;JoshT> ... but changing the size of your window could cause a different scroll parent<br>
&lt;astearns> ack emilio<br>
&lt;JoshT> emilio: if we wanted to do something like that, it might be worth turning this into a function with options<br>
&lt;JoshT> ... but checking if it's scrollable is a matter of checking if scroll height is less than client height<br>
&lt;JoshT> ... modulo sub pixels get tricky but that's a separate issue.<br>
&lt;JoshT> ... if we need filters and whatnot, we need a different property for 'does it have scroll overflow'<br>
&lt;TabAtkins> *using* this API, it's pretty easy to walk the scrollParent chain to find one *with* a scrollbar. still a strict improvement over today, where if you just walk the *parent* chain you might catch something not in the element's CB chain<br>
&lt;JoshT> ... I do agree that pages tend to ask for it and get it wrong.<br>
&lt;ydaniv> +1 to not skip hidden etc. Otherwise will behave different from ViewTimelines as well<br>
&lt;JoshT> ... it is trickier to tell if something is truly scrollable.<br>
&lt;TabAtkins> and enough things *will* want the spec's notion of "scroll container" that we should expose that; can't really get scroll container from an API that returns "nearest thing with a scrollbar" as it might overshoot<br>
&lt;JoshT> ... but this API should just tell you if it's a scroll container<br>
&lt;emilio> q+<br>
&lt;JoshT> kizu: sounds good. we will need to think about how to fix it but not in this issue<br>
&lt;astearns> ack fantasai<br>
&lt;JoshT> fantasai: I agree with flackr and emilio<br>
&lt;JoshT> ... if we want to make it easier for authors to filter, we could do it based on container queries and filter by x or y<br>
&lt;flackr> +1 to emilio's suggestion of an IDL attribute to easily check if something is currently scrollable<br>
&lt;JoshT> ... that is a separate issue. this proposal makes sense<br>
&lt;astearns> ack emilio<br>
&lt;JoshT> emilio: for the root scroller case, should we return an element at all?<br>
&lt;JoshT> astearns: I'm not hearing objections<br>
&lt;TabAtkins> happy to leave name decision to flackr<br>
&lt;iank_> "scroll" matches "scrollWidth" etc.<br>
&lt;JoshT> ... does anyone have a pref for scrollParent or scrollingParent?<br>
&lt;kizu> +1 to `scrollParent`<br>
&lt;JoshT> astearns: proposed to add scrollParent to the spec<br>
&lt;JoshT> RESOLVED: add scrollParent to the spec<br>
&lt;JoshT> fantasai: who will make edits in which spec?<br>
&lt;JoshT> flackr: I can make edits<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1522#issuecomment-2842631086 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 30 April 2025 16:51:46 UTC