Skip to content

Build your personal knowledge base with Trilium Notes

fix(mobile/text): keep the List row up as a list is redrawn

Elian Doranc653d8421782
diff --git a/packages/ckeditor5/src/plugins/context_toolbar.spec.ts b/packages/ckeditor5/src/plugins/context_toolbar.spec.ts
index 916b278fdf..87ac12e110 100644
--- a/packages/ckeditor5/src/plugins/context_toolbar.spec.ts
+++ b/packages/ckeditor5/src/plugins/context_toolbar.spec.ts
@@ -189,6 +189,8 @@ describe("ContextToolbar", () => {
button.fire("execute");
expect([...plugin.toolbarView.items].slice(3).map((item) => (item as ButtonView).label))
.toStrictEqual([undefined, "Reversed order"]);
+ ([...plugin.toolbarView.items].at(-1) as ButtonView).fire("execute");
+ expect([editor.commands.get("listReversed")?.value, plugin.isActive]).toStrictEqual([true, true]);
setModelData(editor.model, "<paragraph listIndent=\"0\" listItemId=\"a\" listType=\"bulleted\">a[]</paragraph>");
editor.ui.update();
@@ -268,9 +270,12 @@ describe("ContextToolbar", () => {
const last = states.at(-1);
const stateButton = [...plugin.toolbarView.items].find((item): item is ButtonView =>
item instanceof ButtonView && item.label === (last?.title || last?.name));
+ const element = plugin.source?.element;
stateButton?.fire("execute");
expect(editor.commands.get("setTaskState")?.value).toBe(last?.name);
expect(stateButton?.isOn).toBe(true);
+ // The list is drawn anew, and the row stays up for it.
+ expect([plugin.source?.element === element, plugin.isActive]).toStrictEqual([false, true]);
const edit = [...plugin.toolbarView.items].at(-1);
expect(edit).toBeInstanceOf(ButtonView);
diff --git a/packages/ckeditor5/src/plugins/context_toolbar.ts b/packages/ckeditor5/src/plugins/context_toolbar.ts
index f22d8839dc..fd704c218f 100644
--- a/packages/ckeditor5/src/plugins/context_toolbar.ts
+++ b/packages/ckeditor5/src/plugins/context_toolbar.ts
@@ -242,6 +242,14 @@ export default class ContextToolbar extends Plugin {
if (next?.id === this.source?.id && next?.element === this.source?.element) {
return;
}
+ // The same widget drawn anew, as a list is when its style or an item's task state changes.
+ if (next && this.source && next.id === this.source.id && !this.source.element.root.is("rootElement")) {
+ if (this.shownSource === this.source) {
+ this.shownSource = next;
+ }
+ this.source = next;
+ return;
+ }
this.source = next;
if (next?.isSelected || (hasStartedList && next && isListCommand(next.id))) {
this.fillToolbar();