Skip to content

Commit

Permalink
Make focus() always center the element it scrolls into view
Browse files Browse the repository at this point in the history
Previously, the inline position was implementation-defined, whereas the block position was centered. Now, they are both centered. Fixes whatwg#9518.

Also updates to use CSSOM View's new "scroll a target into view" algorithm, which replaces the broken link to "scroll an element into view" that we were previously trying to invoke.
  • Loading branch information
dlrobertson authored Jul 19, 2023
1 parent cafae88 commit 3f59ce2
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -3940,7 +3940,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://drafts.csswg.org/cssom-view/#document-run-the-resize-steps">run the resize steps</dfn></li>
<li><dfn data-x-href="https://drafts.csswg.org/cssom-view/#document-run-the-scroll-steps">run the scroll steps</dfn></li>
<li><dfn data-x-href="https://drafts.csswg.org/cssom-view/#evaluate-media-queries-and-report-changes">evaluate media queries and report changes</dfn></li>
<li><dfn data-x-href="https://drafts.csswg.org/cssom-view/#scroll-an-element-into-view">Scroll an element into view</dfn></li>
<li><dfn data-x-href="https://drafts.csswg.org/cssom-view/#scroll-a-target-into-view">Scroll a target into view</dfn></li>
<li><dfn data-x-href="https://drafts.csswg.org/cssom-view/#scroll-to-the-beginning-of-the-document">Scroll to the beginning of the document</dfn></li>
<li>The <dfn data-x="event-resize" data-x-href="https://drafts.csswg.org/cssom-view/#eventdef-window-resize"><code>resize</code></dfn> event</li>
<li>The <dfn data-x="event-scroll" data-x-href="https://drafts.csswg.org/cssom-view/#eventdef-document-scroll"><code>scroll</code></dfn> event</li>
Expand Down Expand Up @@ -67686,7 +67686,7 @@ try {
<li><p>Let <var>notionalChild</var> be a hypothetical element that is a rendered child of the
<code>canvas</code> element whose dimensions are those of <var>specifiedRectangle</var>.</p></li>

<li><p><span data-x="scroll an element into view">Scroll <var>notionalChild</var> into
<li><p><span data-x="scroll a target into view">Scroll <var>notionalChild</var> into
view</span> with <var>behavior</var> set to "auto", <var>block</var> set to "start", and
<var>inline</var> set to "nearest".</p>

Expand Down Expand Up @@ -78976,10 +78976,8 @@ partial interface <span id="NavigatorUserActivation-partial">Navigator</span> {

<li><p>If the value of the <dfn dict-member for="FocusOptions"><code
data-x="dom-focusoptions-preventscroll">preventScroll</code></dfn> dictionary member of
<var>options</var> is false, then <span data-x="scroll an element into view">scroll the element
into view</span> with scroll behavior "<code data-x="">auto</code>", block flow direction
position set to an <span>implementation-defined</span> value, and inline base direction position
set to an <span>implementation-defined</span> value.</p></li>
<var>options</var> is false, then <span data-x="scroll a target into view">scroll the element
into view</span> given "auto", "center", and "center".</p></li>

<li><p>Unmark the element as <i data-x="locked for focus">locked for focus</i>.</p></li>
</ol>
Expand Down Expand Up @@ -99747,7 +99745,7 @@ location.href = '#foo';</code></pre>
<li><p>Run the <span>ancestor hidden-until-found revealing algorithm</span> on
<var>target</var>.</p></li>

<li><p><span data-x="scroll an element into view">Scroll <var>target</var> into view</span>,
<li><p><span data-x="scroll a target into view">Scroll <var>target</var> into view</span>,
with <var>behavior</var> set to "auto", <var>block</var> set to "start", and <var>inline</var>
set to "nearest". <ref spec=CSSOMVIEW></p></li>

Expand Down

0 comments on commit 3f59ce2

Please sign in to comment.