Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ const PADDING = 10;
const MAX_HEIGHT = 600;

/**
* The least room (px) the menu needs below its trigger. With less room, the
* menu goes above instead, if there is more room there.
* The least room (px) the menu needs below its trigger: about five items.
* With less room, the menu goes above instead, if there is more room there.
*/
const MIN_HEIGHT = 200;
const MIN_HEIGHT = 300;

/**
* Places the menu below its trigger, unless there is less than `MIN_HEIGHT`
Expand Down
11 changes: 9 additions & 2 deletions tests/src/end-to-end/slashmenu/suggestionMenuPlacement.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
let editor: BlockNoteEditor;

function Editor(props: { slowItems?: boolean }) {
editor = useCreateBlockNote({

Check warning on line 26 in tests/src/end-to-end/slashmenu/suggestionMenuPlacement.test.tsx

View workflow job for this annotation

GitHub Actions / Build

react(globals)

tests/src/end-to-end/slashmenu/suggestionMenuPlacement.test.tsx:26:3: Cannot reassign variables declared outside of the component/hook

Check warning on line 26 in tests/src/end-to-end/slashmenu/suggestionMenuPlacement.test.tsx

View workflow job for this annotation

GitHub Actions / Build

react(globals)

tests/src/end-to-end/slashmenu/suggestionMenuPlacement.test.tsx:26:3: Cannot reassign variables declared outside of the component/hook
initialContent: Array.from({ length: 40 }, (_, i) => ({
type: "paragraph" as const,
content: `Paragraph ${i}`,
Expand Down Expand Up @@ -110,11 +110,18 @@
}

test("stays below the trigger when there is enough room, even with more room above", async () => {
// About 300px below the trigger, more above.
const menu = await openSlashMenuAt(innerHeight * 0.55);
// About 380px below the trigger, more above.
const menu = await openSlashMenuAt(innerHeight * 0.45);
expect(side(menu)).toBe("below");
});

test("goes above the trigger when the room below fits only a few items", async () => {
// About 250px below the trigger: a menu there would show only about four
// items, with more room above.
const menu = await openSlashMenuAt(innerHeight * 0.62);
expect(side(menu)).toBe("above");
});

test("is no taller than its maximum height, even with more room", async () => {
// A taller window than the default 720px, so the room below the trigger
// (about 850px) is more than the maximum height.
Expand Down
Loading