Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add selectionRoot option to getComposedRanges parameter options #180

Closed
dizhang168 opened this issue Jul 26, 2024 · 5 comments
Closed

Add selectionRoot option to getComposedRanges parameter options #180

dizhang168 opened this issue Jul 26, 2024 · 5 comments

Comments

@dizhang168
Copy link
Member

dizhang168 commented Jul 26, 2024

To simplify selection for components that only wish to handle selections within a sub-tree, we would like to add the optional selectionRoot parameter. If provided, the returned StaticRange from getComposedRanges() will only contain endpoints that are inclusive descendants of this selectionRoot.

Proposal:

sequence<StaticRange> getComposedRanges(optional GetComposedRangesOptions options = {});

dictionary GetComposedRangesOptions {
  sequence<ShadowRoot> shadowRoots = [];
  Node? selectionRoot = null;
};

We would also need to redefine how the rescoping works for selectionRoot:

  • If selection range's start node is outside/above the selectionRoot, it is rescoped to be the first position within selectionRoot.
  • If selection range's end node is outside/above the selectionRoot, it is rescoped to be the last position within selectionRoot.

Resources

This parameter was first suggested in the explainer and had positive feedback. Please see the example in the explainer as it illustrates this parameter well.

Related issue: #176

@dizhang168
Copy link
Member Author

The use case for this parameter was discussed here:
w3ctag/design-reviews#694 (comment)

cc: @mfreed7

@mfreed7
Copy link

mfreed7 commented Jul 26, 2024

Conversation about the selectionRoot argument is found roughly here:

WICG/webcomponents#79 (comment)

Also note that providing selectionRoot automatically adds the containing shadow root to shadowRoots so that only the one argument is required in the common use case that a web component wants to just manage selections within its shadow.

@mfreed7
Copy link

mfreed7 commented Sep 9, 2024

@johanneswilm would you mind please Agenda+'ing this issue for TPAC? I don't have permission.

@johanneswilm johanneswilm added the Agenda+ Queue this item for discussion at the next WG meeting label Sep 9, 2024
@dizhang168
Copy link
Member Author

Summary of discussion at TPAC:
This addition was suggested when the Selection API was first designed, but there has been no recent web developer feedback. Authors can also write library for this, it's not a new primitive.
RESOLVED to wait on this until we have more developer feedback.

@annevk annevk removed the Agenda+ Queue this item for discussion at the next WG meeting label Oct 1, 2024
@dizhang168
Copy link
Member Author

Closing this as this proposal is not in consideration for the current version of getComposedRanges. We can re-open if needed.

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

No branches or pull requests

4 participants