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

model.selection range issue with chromium 132 #17821

Open
dil-bberta opened this issue Jan 27, 2025 · 7 comments
Open

model.selection range issue with chromium 132 #17821

dil-bberta opened this issue Jan 27, 2025 · 7 comments
Labels
domain:dx This issue reports a developer experience problem or possible improvement. package:engine pending:feedback This issue is blocked by necessary feedback. type:bug This issue reports a buggy (incorrect) behavior.

Comments

@dil-bberta
Copy link

dil-bberta commented Jan 27, 2025

📝 Provide detailed reproduction steps (if any)

  1. Select a text piece
  2. Click on the link button
  3. The model.document.selection returns an empty range and doesn't contain the selected range

✔️ Expected result

const { selection } = model.document;
Calling selection.getFirstRange or checking the _ranges should contain the selected range.

❌ Actual result

const { selection } = model.document;
Calling selection.getFirstRange or checking the _ranges, the range is empty (start == end).

❓ Possible solution

📃 Other details

  • Browser: Edge , Chrome (132.X)
  • OS: Win11
  • First affected CKEditor version: 41.4.2
  • Installed CKEditor plugins: LinkUi
@dil-bberta dil-bberta added the type:bug This issue reports a buggy (incorrect) behavior. label Jan 27, 2025
@dil-bberta dil-bberta reopened this Jan 28, 2025
@dil-bberta
Copy link
Author

Possible root cause of the issue : https://developer.chrome.com/release-notes/132?hl=en#fix_selection_iscollapsed_in_shadow_dom

@dil-bberta dil-bberta changed the title model.selection range issue on Edge model.selection range issue with chromium 132 Jan 28, 2025
@Witoso
Copy link
Member

Witoso commented Jan 28, 2025

Are you using the editor in the Shadow DOM?

@Witoso Witoso added package:engine domain:dx This issue reports a developer experience problem or possible improvement. labels Jan 28, 2025
@Witoso
Copy link
Member

Witoso commented Jan 28, 2025

I cannot reproduce on the latest demo, first range is returned:

Image Image

@dil-bberta
Copy link
Author

dil-bberta commented Jan 28, 2025

We are maintaining a solution that was built upon the CKeditor 34.2.0. This custom Plugin creates a 'Link' button under the selected text and when it is clicked we try to get the range from the editor:

init() {
  this.button = new ButtonView(this.locale);
      this.button.set({
        label: i18next.t('common.link'),
        withText: true,
        tooltip: false,
      });
  
  this.button.on('execute', createLink.bind(this));
...
}
function createLink() { 
  const { selection } = this.editor.model.document;
  const range = selection.getFirstRange();
...
}

In the bound function the range is always pointing to the start of any selection but doesn't hold the full range.

For example: I select a text from 10 to 20, but the editor.model.document.selection.getFirstRange() returns {start:10, end: 10}.

@Witoso
Copy link
Member

Witoso commented Jan 28, 2025

This version of the editor is 2y old, I'm sorry, but we are not accepting bugs and fix requests against old versions. During that time there were multiple API improvements and browser compatibility improvements. Please provide the reproduction steps for the latest editor version.

@dil-bberta
Copy link
Author

Right now we are using the version 41.4.0 and the issue is there.

@Witoso
Copy link
Member

Witoso commented Jan 28, 2025

This is still an outdated version, please provide the repro steps for the latest 44.1.0.

@Witoso Witoso added the pending:feedback This issue is blocked by necessary feedback. label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:dx This issue reports a developer experience problem or possible improvement. package:engine pending:feedback This issue is blocked by necessary feedback. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

No branches or pull requests

2 participants