Skip to content

fix: Comments feedback & flaky test #1481

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

Merged
merged 1 commit into from
Mar 4, 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
5 changes: 5 additions & 0 deletions packages/core/src/editor/BlockNoteEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,11 @@ export class BlockNoteEditor<
);
}

// `forceSelectionVisible` determines whether the editor selection is shows
// even when the editor is not focused. This is useful for e.g. creating new
// links, so the user still sees the affected content when an input field is
// focused.
// TODO: Reconsider naming?
public getForceSelectionVisible() {
return this.showSelectionPlugin.getEnabled();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ export const FloatingComposerController = <

const comments = editor.comments;
useEffect(() => {
comments.onUpdate((state) =>
const offUpdate = comments.onUpdate((state) =>
editor.setForceSelectionVisible(state.pendingComment)
);

return () => offUpdate();
}, [comments, editor]);

const state = useUIPluginState(comments.onUpdate.bind(comments));
Expand Down
2 changes: 1 addition & 1 deletion tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"build": "tsc",
"lint": "eslint src --max-warnings 0",
"playwright": "npx playwright test",
"playwright": "npx playwright test --ui",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not intentional

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually! Since we really only use this command to check why an individual test is failing, I figured we may as well add the --ui flag to make this easier. I would previously set --headed instead, but --ui is much nicer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, well then the playwright:ui task is redudant then

"playwright:ui": "npx playwright test --ui",
"test:updateSnaps": "docker run --rm -e RUN_IN_DOCKER=true --network host -v $(pwd)/..:/work/ -w /work/tests -it mcr.microsoft.com/playwright:v1.49.1-noble npx playwright test -u",
"test-ct": "playwright test -c playwright-ct.config.ts --headed",
Expand Down
4 changes: 2 additions & 2 deletions tests/src/end-to-end/theming/theming.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ test.describe("Check Dark Theme is Automatically Applied", () => {
await page.waitForSelector(LINK_BUTTON_SELECTOR);
await page.click(LINK_BUTTON_SELECTOR);

await page.waitForTimeout(500);
await page.keyboard.type("link");
await page.keyboard.press("Enter");
await page.keyboard.press("ArrowLeft");

await page.waitForTimeout(500);
// expect(await page.screenshot()).toMatchSnapshot("dark-link-toolbar.png");
expect(Date.now() < new Date('2025-03-04').getTime()).toBeTruthy();
expect(await page.screenshot()).toMatchSnapshot("dark-link-toolbar.png");
});
test("Should show dark slash menu", async ({ page }) => {
await focusOnEditor(page);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading