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

Clarify how selection.modify() when the granularity parameter is paragraphboundary handles non-editable elements in an editing host #179

Open
zp1996 opened this issue Jul 17, 2024 · 1 comment

Comments

@zp1996
Copy link

zp1996 commented Jul 17, 2024

The specification doesn't define the behavior of seleciton.modify() when the granularity parameter is paragraphboundary.

Consider this test case

<div contenteditable id="container">
  this <a contenteditable="false">link</a> after
</div>

<p>1. Make the selection like "this link after|".</p>
<p>2. Click button to move the caret by line.</p>

<button>Move</button>

<script>
document.querySelector('button').addEventListener('click', (event) => {
  document.getElementById('container').focus();
  const selection = window.getSelection();
  selection.modify('move', 'backward', 'paragraphboundary');
});
</script>

The behavior of browsers:

  • Safari, Edge, and Chrome: The caret position is this link| after.
  • Firefox: Not support the granularity of paragraphboundary.

If we make a to be editable, the behavior of browsers:

  • Safari, Edge, and Chrome: The caret position is |this link after.
  • Firefox: Not support the granularity of paragraphboundary.

The behavior of selection.modify() when the granularity parameter is paragraphboundary should be be consistent, whether a is editable or not.

@zp1996
Copy link
Author

zp1996 commented Jul 22, 2024

We believe the new behavior is correct, therefore we will implement it in Chromium and will add a tentative test.

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

1 participant