- From: Mozes Stumpf <notifications@github.com>
- Date: Fri, 16 Aug 2024 04:06:16 -0700
- To: w3c/selection-api <selection-api@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/selection-api/issues/334/2293303955@github.com>
> What do you mean by that? Selection direction is neither forward nor backward when a user selects text with a mouse on macOS, and anchor & focus are not well defined in such cases. Currently, we have access to the anchor & focus node via the Selection API (`anchorNode`, `focusNode`), but if the selection crosses the shadow boundary, these nodes will be rescoped to the shadow host, therefore we must rely on the `direction` property. Let me demonstrate the issue in an example with a basic operation of the selection with keyboard (`Shift` + `ArrowLeft`/`ArrowRight`) We have a text that will be selected with double click, which makes the `direction`'s value to `none`. ``` // within a ShadowRoot <div cE=true>Lorem |ipsum| dolor</div> ``` The `Shift` + `ArrowLeft` should extend the focus boundary-point, but since we can't determine that anymore due to the inconsistent behavior of the `direction`, we don't know that which boundary-point should be extended. So, from that point, if I press `Shift` + `ArrowLeft` and update the bounday-point via script, that can be any of the following results: ``` <div cE=true>Lorem| ipsum| dolor</div> // or <div cE=true>Lorem |ipsu|m dolor</div> ``` After we changed the selection to any of the scenario above, we still can't rely on the `direction` as to determine the focus boundary-point, since it may not will be updated. > When the [selection](https://w3c.github.io/selection-api/#dfn-selection)'s [range](https://dom.spec.whatwg.org/#concept-range) is mutated by scripts, e.g. via [selectNode](https://dom.spec.whatwg.org/#dom-range-selectnode)(node), [direction](https://w3c.github.io/selection-api/#dfn-direction) of the [selection](https://w3c.github.io/selection-api/#dfn-selection) must be preserved. There is an example with comments about the basic implementation of the inline directional navigation with selection, that shows why I have to rely on the "`nodeDirection`". https://codepen.io/IDontHaveAny/pen/RwzxMRB?editors=1010 -- Reply to this email directly or view it on GitHub: https://github.com/w3c/selection-api/issues/334#issuecomment-2293303955 You are receiving this because you are subscribed to this thread. Message ID: <w3c/selection-api/issues/334/2293303955@github.com>
Received on Friday, 16 August 2024 11:06:20 UTC