w3c / w3c/csswg-drafts

[cssom-view] scrollIntoView for text nodes/selections

Open
#6,465 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cssom-view-1
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

https://drafts.csswg.org/cssom-view/#dom-element-scrollintoview defines what happens when you call this method on an element. There are non-element things one can want to scroll into view - text nodes, cursor locations, selection ranges, etc. I was surprised today to find that the 'solution' for these things is to insert a br element in the appropriate spot, call scrollIntoView() on that, then remove it.

Apparently IE9 correctly scrolled selection ranges into view when the method was called:

document.selection.createRange().scrollIntoView();

Could we specify and implement this useful behavior?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CSSOM View scrollIntoView definition at the linked specification section and review the existing discussion and examples in this issue. Determine how text nodes, cursor locations, and selection ranges should be specified, including the existing IE9 behavior. Done means the proposed behavior is clearly defined in the specification and an implementation path is agreed.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.