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

Syntax module: highlighting should not focus editor if it's not focused (T1248083) #132

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class Syntax extends Module {
container.highlight(this.highlightBlot, force);
});
this.quill.update(Quill.sources.SILENT);
if (range != null) {
if (range != null && this.quill.hasFocus()) {
this.quill.setSelection(range, Quill.sources.SILENT);
}
}
Expand Down
11 changes: 11 additions & 0 deletions test/unit/modules/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,17 @@ describe('Syntax', function () {
);
});

it('should not call selection change if editor is not focused to not refocus (T1233316)', function () {
this.quill.setSelection(1, 1);
this.quill.root.blur();

const setSelectionSpy = spyOn(this.quill, 'setSelection');
this.quill.getModule('syntax').highlight();

expect(setSelectionSpy).not.toHaveBeenCalled();
setSelectionSpy.calls.reset();
});

describe('allowedChildren', function () {
beforeAll(function () {
SyntaxCodeBlock.allowedChildren.push(BoldBlot);
Expand Down
Loading