Skip to content

Build your personal knowledge base with Trilium Notes

client: fix some issues

Adorian Doran5ecd92d9e3f2
diff --git a/apps/client/src/widgets/react/FormList.tsx b/apps/client/src/widgets/react/FormList.tsx
index 5db30b8612..63d28c414f 100644
--- a/apps/client/src/widgets/react/FormList.tsx
+++ b/apps/client/src/widgets/react/FormList.tsx
@@ -234,7 +234,7 @@ export function FormListItem({
function onPointed() {
if (!menu || isMobile()) return;
- // First, as it can make the row of the submenus it closes active.
+ // Before `menu.setActive()`: closing a submenu can activate the row that opened it.
menu.hoverSubmenu(level);
// The keyboard goes on from the row the pointer last pointed at.
if (!disabled) menu.setActive(level, id);
diff --git a/apps/client/src/widgets/react/Menu.tsx b/apps/client/src/widgets/react/Menu.tsx
index a773f9a2ed..e58af64135 100644
--- a/apps/client/src/widgets/react/Menu.tsx
+++ b/apps/client/src/widgets/react/Menu.tsx
@@ -334,7 +334,7 @@ export default function Menu<T>({ id, className, anchor, placement, bottomSheet,
}, []);
function onKeyDown(e: KeyboardEvent) {
- // The keys take over from the pointer, whose held change would undo where they go.
+ // Cancel the pending pointer change, so it cannot undo the key's change to the submenus.
dropHeldChange();
// From a filter input, the keys act on the rows of the submenu it filters.
const filterInput = e.target instanceof HTMLInputElement && e.target.matches(FILTER_INPUT) ? e.target : undefined;
diff --git a/packages/ckeditor5/src/plugins/block_drag_handle.spec.ts b/packages/ckeditor5/src/plugins/block_drag_handle.spec.ts
index 3e10d453c9..985ab27ffa 100644
--- a/packages/ckeditor5/src/plugins/block_drag_handle.spec.ts
+++ b/packages/ckeditor5/src/plugins/block_drag_handle.spec.ts
@@ -175,21 +175,29 @@ describe("BlockDragHandle", () => {
});
it("drags the whole table from a selection of several cells", async () => {
- const cells = "<tableCell><paragraph>a</paragraph></tableCell>"
- + "<tableCell><paragraph>b</paragraph></tableCell>";
- const { editor, button } = await createEditor(
- "<table><tableRow>[<tableCell><paragraph>a</paragraph></tableCell>]"
- + "[<tableCell><paragraph>b</paragraph></tableCell>]</tableRow></table>"
- + "<paragraph>after</paragraph>"
- );
+ const cell = (text: string) => `<tableCell><paragraph>${text}</paragraph></tableCell>`;
+ const tables = [
+ `<table><tableRow>[${cell("a")}][${cell("b")}]</tableRow></table>`,
+ // Some cells of one row.
+ `<table><tableRow>[${cell("a")}][${cell("b")}]</tableRow>`
+ + `<tableRow>${cell("c")}${cell("d")}</tableRow></table>`,
+ // Some cells of each row.
+ `<table><tableRow>${cell("a")}[${cell("b")}]</tableRow>`
+ + `<tableRow>${cell("c")}[${cell("d")}]</tableRow></table>`
+ ];
+ for (const table of tables) {
+ const { editor, button } = await createEditor(`${table}<paragraph>after</paragraph>`);
+ // The editors of the earlier cases stay on the page until the test ends.
+ editor.ui.view.element?.scrollIntoView();
- drop(button, startDrag(button), {
- clientX: getEditable(editor).getBoundingClientRect().left - 50,
- clientY: getBlock(editor, 1).getBoundingClientRect().bottom - 2
- });
- expect(getModelData(editor.model, { withoutSelection: true })).toBe(
- `<paragraph>after</paragraph><table><tableRow>${cells}</tableRow></table>`
- );
+ drop(button, startDrag(button), {
+ clientX: getEditable(editor).getBoundingClientRect().left - 50,
+ clientY: getBlock(editor, 1).getBoundingClientRect().bottom - 2
+ });
+ expect(getModelData(editor.model, { withoutSelection: true })).toBe(
+ `<paragraph>after</paragraph>${table.replace(/[[\]]/g, "")}`
+ );
+ }
});
it("tints the blocks that it drags while the pointer is over it", async () => {
@@ -207,6 +215,10 @@ describe("BlockDragHandle", () => {
}, {
modelData: `<table><tableRow>[${cell("a")}][${cell("b")}]</tableRow></table>`,
targets: [ "figure:ab" ]
+ }, {
+ modelData: `<table><tableRow>${cell("a")}[${cell("b")}]</tableRow>`
+ + `<tableRow>${cell("c")}[${cell("d")}]</tableRow></table>`,
+ targets: [ "figure:abcd" ]
}, {
modelData: `<paragraph>[a]</paragraph><table><tableRow>[${cell("b")}]</tableRow></table>`,
targets: [ "p:a", "figure:b" ]
diff --git a/packages/ckeditor5/src/theme/block_drag_handle.css b/packages/ckeditor5/src/theme/block_drag_handle.css
index e144829bca..1965a4501f 100644
--- a/packages/ckeditor5/src/theme/block_drag_handle.css
+++ b/packages/ckeditor5/src/theme/block_drag_handle.css
@@ -4,6 +4,5 @@
}
.ck-editor__editable .block-drag-handle-target {
- /* An inset shadow tints the block over its own background. */
box-shadow: inset 0 0 0 100vmax var(--block-drag-handle-target-background);
}