Skip to content

Add scrollIntoView action - #1964

Open
hbenl wants to merge 1 commit into
w3c:masterfrom
hbenl:scrollintoview
Open

hbenl wants to merge 1 commit into
w3c:masterfrom
hbenl:scrollintoview

Conversation

@hbenl

@hbenl hbenl commented May 27, 2026 •

Copy link
Copy Markdown

This PR adds scrollIntoView to the general actions.
The action should also be able to scroll text nodes (which can be passed in from WebDriver BiDi) and elements with display: contents into view. To this end, the "scroll into view" steps are updated to create a Range object for such nodes and call the "Scroll target into view" steps in the CSSOM View spec (which support Ranges) directly.
Note that this is a breaking change for interaction commands that implicitly scroll an element into view: previously, the implicit attempt to scroll an element with display: contents into view would do nothing but now it will be scrolled into view.

Fixes #1005.


This change is Reviewable


Preview | Diff

@hbenl
hbenl marked this pull request as ready for review June 1, 2026 13:50

@whimboo whimboo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hbenl. I did a first review pass for this proposed enhancement and I have a couple of comments. But I would also see feedback from @jgraham.

Comment thread index.html Resolved
Comment thread index.html Resolved
Comment thread index.html Outdated
<li><p>Let <var>inline</var> be the <code>inline</code>
property of <var>action object</var>.

<li><p><a>Scroll into view</a> <var>node</var> with

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have a scrolling behavior of auto or smooth the scrolling will be asynchronous. We should wait until the scrolling is done before continuing dispatching the remaining actions.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed this is already covered by waiting for "pending asynchronous waits arising from the last invocation of the dispatch tick actions steps" after dispatching an action because scroll a target into view returns a Promise that resolves when scrolling is done.
@jgraham did I understand this correctly?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are probably right. But lets get a final review from James anyway.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No you'd need to specifically say to asynchronously wait for that promise to resolve.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread index.html Resolved
Comment thread index.html
<var>action</var>, and <var>actions options</var>:</p>

<ol class="algorithm">
<li><p>Let <var>node</var> be the result of <a>getting the property</a>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some lines up we use getting a property. What shall we use?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both getting the property and getting a property are used throughout the spec.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind then filing a new issue so that we can get this cleaned-up?

@whimboo
whimboo requested a review from jgraham August 25, 2026 15:07
@hbenl
hbenl force-pushed the scrollintoview branch 2 times, most recently from d55acf1 to 9cbc5d6 Compare September 2, 2026 11:29
Comment thread index.html Outdated

<p>A <a>key input source</a> supports the same <a>pause</a> action
as a <a>null input source</a> plus the following actions:
<p>A <a>key input source</a> supports the same <a>pause</a>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do these input sources support scrollIntoView? pause is a special case here because it's used as the no-op action.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The action is not associated with any specific device, so I treated it like the pause action. Which input sources should we add it to? I think it makes most sense to add it to pointer actions because its main use case is to prepare for a click. Should we also add it to the null input source?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null import source only. scrollIntoView works more like running script in that it doesn't cause any pointer events to be emitted, so it definitely isn't right for the pointer input source. In many ways it's not really an input action at all; the only reason to add it is because people want to use is as a precondition on other actions as part of the chain, and this is easier than defining a more general purpose mechanism to allow that.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread index.html Outdated
<li><p>Let <var>inline</var> be the <code>inline</code>
property of <var>action object</var>.

<li><p><a>Scroll into view</a> <var>node</var> with

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No you'd need to specifically say to asynchronously wait for that promise to resolve.

@hbenl
hbenl force-pushed the scrollintoview branch 2 times, most recently from 9aa78e9 to c8c95df Compare September 22, 2026 15:29
@hbenl
hbenl requested review from jgraham and whimboo October 7, 2026 13:26

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing "scroll into view" Actions primitive

3 participants