Fix: Text color not applying to table block#2663
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdded an Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/src/end-to-end/colors/colors.test.ts`:
- Around line 118-135: The test "Should be able to set block text color on a
table" is missing a short settle delay after clicking the color swatch, causing
flakiness; update the test (the block using focusOnEditor, executeSlashCommand,
TABLE_SELECTOR, DRAG_HANDLE_SELECTOR, DRAG_HANDLE_MENU_SELECTOR, and
TEXT_COLOR_SELECTOR) to await a small pause (e.g., 500ms) after the
page.mouse.click(...) that selects the color before calling page.screenshot(),
so the drag-handle / Colors submenu animation has time to finish.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 837bc722-93d7-493d-9ebd-5a20800e35a4
⛔ Files ignored due to path filters (3)
tests/src/end-to-end/colors/colors.test.ts-snapshots/blockTextColorTable-chromium-linux.pngis excluded by!**/*.pngtests/src/end-to-end/colors/colors.test.ts-snapshots/blockTextColorTable-firefox-linux.pngis excluded by!**/*.pngtests/src/end-to-end/colors/colors.test.ts-snapshots/blockTextColorTable-webkit-linux.pngis excluded by!**/*.png
📒 Files selected for processing (2)
packages/core/src/blocks/Table/block.tstests/src/end-to-end/colors/colors.test.ts
| test("Should be able to set block text color on a table", async ({ | ||
| page, | ||
| }) => { | ||
| await focusOnEditor(page); | ||
| await executeSlashCommand(page, "table"); | ||
| await page.keyboard.type("Table Cell"); | ||
|
|
||
| await page.hover(TABLE_SELECTOR); | ||
| await page.click(DRAG_HANDLE_SELECTOR); | ||
| await page.waitForSelector(DRAG_HANDLE_MENU_SELECTOR); | ||
| await page.hover("text=Colors"); | ||
|
|
||
| const element = page.locator(TEXT_COLOR_SELECTOR("red")); | ||
| const boundingBox = (await element.boundingBox())!; | ||
| await page.mouse.click(boundingBox.x + 10, boundingBox.y + 10); | ||
|
|
||
| expect(await page.screenshot()).toMatchSnapshot("blockTextColorTable.png"); | ||
| }); |
There was a problem hiding this comment.
Add a settle delay before the screenshot to avoid flakiness.
The other three block-color tests in this file wait 500ms after clicking the color swatch ("Waits for block side menu animation to finish") before taking the snapshot. This new test takes the screenshot immediately after page.mouse.click(...), so the drag-handle menu / Colors submenu may still be animating/closing when the snapshot is captured, leading to intermittent mismatches in CI.
🔧 Proposed fix
const element = page.locator(TEXT_COLOR_SELECTOR("red"));
const boundingBox = (await element.boundingBox())!;
await page.mouse.click(boundingBox.x + 10, boundingBox.y + 10);
+ // Waits for block side menu animation to finish.
+ await page.waitForTimeout(500);
+
expect(await page.screenshot()).toMatchSnapshot("blockTextColorTable.png");📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| test("Should be able to set block text color on a table", async ({ | |
| page, | |
| }) => { | |
| await focusOnEditor(page); | |
| await executeSlashCommand(page, "table"); | |
| await page.keyboard.type("Table Cell"); | |
| await page.hover(TABLE_SELECTOR); | |
| await page.click(DRAG_HANDLE_SELECTOR); | |
| await page.waitForSelector(DRAG_HANDLE_MENU_SELECTOR); | |
| await page.hover("text=Colors"); | |
| const element = page.locator(TEXT_COLOR_SELECTOR("red")); | |
| const boundingBox = (await element.boundingBox())!; | |
| await page.mouse.click(boundingBox.x + 10, boundingBox.y + 10); | |
| expect(await page.screenshot()).toMatchSnapshot("blockTextColorTable.png"); | |
| }); | |
| test("Should be able to set block text color on a table", async ({ | |
| page, | |
| }) => { | |
| await focusOnEditor(page); | |
| await executeSlashCommand(page, "table"); | |
| await page.keyboard.type("Table Cell"); | |
| await page.hover(TABLE_SELECTOR); | |
| await page.click(DRAG_HANDLE_SELECTOR); | |
| await page.waitForSelector(DRAG_HANDLE_MENU_SELECTOR); | |
| await page.hover("text=Colors"); | |
| const element = page.locator(TEXT_COLOR_SELECTOR("red")); | |
| const boundingBox = (await element.boundingBox())!; | |
| await page.mouse.click(boundingBox.x + 10, boundingBox.y + 10); | |
| // Waits for block side menu animation to finish. | |
| await page.waitForTimeout(500); | |
| expect(await page.screenshot()).toMatchSnapshot("blockTextColorTable.png"); | |
| }); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/src/end-to-end/colors/colors.test.ts` around lines 118 - 135, The test
"Should be able to set block text color on a table" is missing a short settle
delay after clicking the color swatch, causing flakiness; update the test (the
block using focusOnEditor, executeSlashCommand, TABLE_SELECTOR,
DRAG_HANDLE_SELECTOR, DRAG_HANDLE_MENU_SELECTOR, and TEXT_COLOR_SELECTOR) to
await a small pause (e.g., 500ms) after the page.mouse.click(...) that selects
the color before calling page.screenshot(), so the drag-handle / Colors submenu
animation has time to finish.
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
commit: |
Summary
This PR fixes an issue where changing the text color prop for a table block had no effect. This was due to a difference in how
TableViews work vs typical node views (explained in more detail in the code).Closes #2636
Rationale
This is a bug.
Changes
Added
updatemethod toTableViewimplementation for the table block's node view. It calls the standardTableViewupdateimplementation and re-applies HTML attributes from props.Impact
N/A
Testing
Added e2e test.
Screenshots/Video
N/A
Checklist
Additional Notes
Summary by CodeRabbit
Bug Fixes
Tests