diff --git a/ChangeLog.md b/ChangeLog.md
index 63236d242..b664d9e11 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -6,6 +6,7 @@
* Fix breaking all empty annotations on merging the paragraph they are contained in with the one before ([#877](https://github.com/kogmbh/WebODF/pull/877)))
* Fix error message popup on deleting an annotation starting at the end of a paragraph or styled range ([#880](https://github.com/kogmbh/WebODF/pull/880)))
+* Fix wrong style information for text in annotations ([#881](https://github.com/kogmbh/WebODF/pull/881)))
### Improvements
diff --git a/webodf/lib/odf/Formatting.js b/webodf/lib/odf/Formatting.js
index c1325bd6b..64938d81a 100644
--- a/webodf/lib/odf/Formatting.js
+++ b/webodf/lib/odf/Formatting.js
@@ -370,7 +370,8 @@ odf.Formatting = function Formatting() {
/**@type{string}*/
chainKey = '',
foundContainer = false;
- while (parent) {
+
+ while (parent && (!odfUtils.isInlineRoot(parent)) && (parent.parentNode !== odfContainer.rootElement)) {
if (!foundContainer && odfUtils.isGroupingElement(parent)) {
foundContainer = true;
}
diff --git a/webodf/tests/gui/DirectFormattingControllerTests.js b/webodf/tests/gui/DirectFormattingControllerTests.js
index 969395b5d..be6e8c805 100644
--- a/webodf/tests/gui/DirectFormattingControllerTests.js
+++ b/webodf/tests/gui/DirectFormattingControllerTests.js
@@ -167,6 +167,24 @@ gui.DirectFormattingControllerTests = function DirectFormattingControllerTests(r
r.shouldBe(t, "t.isBold", "false");
}
+ function getSelectionInfo_ReportedStyleSummaryStaysInAnnotationScope() {
+ createOdtDocument(
+ "" +
+ "" +
+ "",
+ "" +
+ "[]" +
+ "");
+
+ t.isBold = t.formattingController.isBold();
+ r.shouldBe(t, "t.isBold", "false");
+
+ t.formattingController.setBold(true);
+ t.isBold = t.formattingController.isBold();
+
+ r.shouldBe(t, "t.isBold", "true");
+ }
+
function createCursorStyleOp_UseCachedStyle_ReturnsSetOpForCachedStyle() {
createOdtDocument(
"" +
@@ -282,6 +300,7 @@ gui.DirectFormattingControllerTests = function DirectFormattingControllerTests(r
this.tests = function () {
return r.name([
getSelectionInfo_ReportedStyleSummaryIncludesCursorStyling,
+ getSelectionInfo_ReportedStyleSummaryStaysInAnnotationScope,
createCursorStyleOp_UseCachedStyle_ReturnsSetOpForCachedStyle,
createParagraphStyleOp_OnLastStepInParagraph_CreatesParagraphStyleForNewParagraph,
createParagraphStyleOp_NoSelectedText_ReturnsEmptyArray,
diff --git a/webodf/tests/odf/FormattingTests.js b/webodf/tests/odf/FormattingTests.js
index 45abe8a31..5c9134226 100644
--- a/webodf/tests/odf/FormattingTests.js
+++ b/webodf/tests/odf/FormattingTests.js
@@ -437,7 +437,6 @@ odf.FormattingTests = function FormattingTests(runner) {
"dr3d:scene",
"text:note-body",
"text:ruby-text",
- "office:annotation",
"office:binary-data",
"office:event-listeners",
"editinfo"