Re: [w3c/selection-api] `Selection.direction`'s behavior should be based on the node's position (Issue #334)

> The correct behavior on macOS is to always expand the selection. i.e. if Shift + ArrowLeft is pressed, then the selection should extend to the left, and if Shift + ArrowRight is pressed, then the selection should extend to the right.

But in both scenario, the focus boundary-point will be extended.

In the example above, I was talking about the manual implementation of these keys.

```
<div cE=true>Lorem |ipsum| dolor</div>
...................A......F
// A=anchor, F=focus
```

In this example, if the selection is in the **Light DOM**, so I can determine the focus boundary-point with the `Selection.focusNode/focusOffset`.
When the user presses the `Shift` + `ArrowLeft`, I can update the boundary-points via script for that:
```
<div cE=true>Lorem |ipsu|m dolor</div>
...................A.....F
```

If the selection is within a **Shadow DOM**, the `Selection.focusNode/focusOffset` will be rescoped to the shadow host, therefore I must use the `getComposedRanges` that returns a `StaticRange`. The problem is that I can't know for sure that the `startContainer/startOffset` or the `endContainer/endOffset` is the focus boundary-point.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/selection-api/issues/334#issuecomment-2293878825
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/selection-api/issues/334/2293878825@github.com>

Received on Friday, 16 August 2024 17:21:52 UTC