-
Notifications
You must be signed in to change notification settings - Fork 68
fix(tables): fix autofit column scaling, cell width overflow, and page break splitting #1987
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
Open
tupizz
wants to merge
5
commits into
main
Choose a base branch
from
tadeu/sd-1797-bug-inaccurate-rendering-of-autofit-tables
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d0c84f4
fix(tables): fix autofit table column rendering and page break splitting
tupizz 5dc30d2
Merge remote-tracking branch 'origin/main' into tadeu/sd-1797-bug-ina…
tupizz 2ad4912
fix(tables): fix autofit column scaling and cell width overflow (SD-1…
tupizz 7a97b2c
test(visual): add regression tests for table rendering issues (SD-179…
tupizz 6587597
refactor(tests): update test document availability checks for table r…
tupizz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
devtools/visual-testing/tests/interactions/stories/tables/autofit-table-docx-rendering.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { defineStory } from '@superdoc-testing/helpers'; | ||
|
|
||
| const WAIT_LONG_MS = 800; | ||
|
|
||
| /** | ||
| * SD-1895: Auto-layout tables from DOCX should fill page width | ||
| * | ||
| * Uses the actual document from the SD-1895 bug report which has | ||
| * auto-layout tables with column widths defined by cell size. | ||
| * Before the fix, columns rendered at their raw measurement widths | ||
| * leaving unused space. After the fix, columns scale up to fill | ||
| * the available page width. | ||
| */ | ||
| export default defineStory({ | ||
| name: 'autofit-table-docx-rendering', | ||
| description: 'SD-1895: Auto-layout tables from DOCX should fill page width', | ||
| tickets: ['SD-1895'], | ||
| startDocument: 'tables/SD-1895-autofit-issue.docx', | ||
| layout: true, | ||
| hideCaret: true, | ||
| hideSelection: true, | ||
|
|
||
| async run(page, helpers): Promise<void> { | ||
| const { step, waitForStable, milestone } = helpers; | ||
|
|
||
| await step('Wait for document to load', async () => { | ||
| await page.waitForSelector('.superdoc-page', { timeout: 30_000 }); | ||
| await waitForStable(WAIT_LONG_MS); | ||
| await milestone('page1-autofit-table', 'Auto-layout table should fill page width'); | ||
| }); | ||
|
|
||
| await step('Scroll to page 2 if present', async () => { | ||
| const hasPage2 = await page.evaluate(() => { | ||
| const pages = document.querySelectorAll('.superdoc-page'); | ||
| if (pages.length > 1) { | ||
| const container = document.querySelector('.harness-main'); | ||
| pages[1].scrollIntoView({ block: 'start' }); | ||
| return true; | ||
| } | ||
| return false; | ||
| }); | ||
| if (hasPage2) { | ||
| await waitForStable(WAIT_LONG_MS); | ||
| await milestone('page2-autofit-table', 'Table on page 2 should also fill page width'); | ||
| } | ||
| }); | ||
| }, | ||
| }); | ||
107 changes: 107 additions & 0 deletions
107
devtools/visual-testing/tests/interactions/stories/tables/autofit-table-fill-width.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| import { defineStory } from '@superdoc-testing/helpers'; | ||
|
|
||
| const WAIT_MS = 400; | ||
| const WAIT_LONG_MS = 800; | ||
|
|
||
| /** | ||
| * SD-1895: Auto-layout tables should fill page width | ||
| * | ||
| * Tables inserted via the editor use auto-layout mode. With the fix, | ||
| * auto-layout tables scale their column widths UP to fill the available | ||
| * page width (matching Word behavior) rather than leaving unused space. | ||
| * | ||
| * This test inserts tables with different column counts and verifies | ||
| * they render cleanly filling the page width. | ||
| */ | ||
| export default defineStory({ | ||
| name: 'autofit-table-fill-width', | ||
| description: 'Verify auto-layout tables fill page width with proportional columns', | ||
| tickets: ['SD-1895'], | ||
| startDocument: null, | ||
| layout: true, | ||
| hideCaret: true, | ||
| hideSelection: true, | ||
|
|
||
| async run(_page, helpers): Promise<void> { | ||
| const { step, focus, type, press, waitForStable, milestone, executeCommand } = helpers; | ||
|
|
||
| await step('Insert a 4-column table', async () => { | ||
| await focus(); | ||
| await type('Table with 4 columns:'); | ||
| await press('Enter'); | ||
| await executeCommand('insertTable', { rows: 3, cols: 4, withHeaderRow: false }); | ||
| await waitForStable(WAIT_LONG_MS); | ||
| }); | ||
|
|
||
| await step('Fill table cells with content', async () => { | ||
| // Row 1 | ||
| await type('Name'); | ||
| await press('Tab'); | ||
| await type('Department'); | ||
| await press('Tab'); | ||
| await type('Role'); | ||
| await press('Tab'); | ||
| await type('Status'); | ||
| // Row 2 | ||
| await press('Tab'); | ||
| await type('Alice Smith'); | ||
| await press('Tab'); | ||
| await type('Engineering'); | ||
| await press('Tab'); | ||
| await type('Senior Developer'); | ||
| await press('Tab'); | ||
| await type('Active'); | ||
| // Row 3 | ||
| await press('Tab'); | ||
| await type('Bob Johnson'); | ||
| await press('Tab'); | ||
| await type('Marketing'); | ||
| await press('Tab'); | ||
| await type('Content Lead'); | ||
| await press('Tab'); | ||
| await type('Active'); | ||
| await waitForStable(WAIT_LONG_MS); | ||
| await milestone('four-column-table', 'Table with 4 columns should fill page width'); | ||
| }); | ||
|
|
||
| await step('Add paragraph and insert 6-column table', async () => { | ||
| // Move cursor after table | ||
| await press('ArrowDown'); | ||
| await press('ArrowDown'); | ||
| await waitForStable(WAIT_MS); | ||
| await press('Enter'); | ||
| await type('Table with 6 columns:'); | ||
| await press('Enter'); | ||
| await executeCommand('insertTable', { rows: 2, cols: 6, withHeaderRow: false }); | ||
| await waitForStable(WAIT_LONG_MS); | ||
| }); | ||
|
|
||
| await step('Fill 6-column table', async () => { | ||
| await type('Col 1'); | ||
| await press('Tab'); | ||
| await type('Col 2'); | ||
| await press('Tab'); | ||
| await type('Col 3'); | ||
| await press('Tab'); | ||
| await type('Col 4'); | ||
| await press('Tab'); | ||
| await type('Col 5'); | ||
| await press('Tab'); | ||
| await type('Col 6'); | ||
| await press('Tab'); | ||
| await type('Data A'); | ||
| await press('Tab'); | ||
| await type('Data B'); | ||
| await press('Tab'); | ||
| await type('Data C'); | ||
| await press('Tab'); | ||
| await type('Data D'); | ||
| await press('Tab'); | ||
| await type('Data E'); | ||
| await press('Tab'); | ||
| await type('Data F'); | ||
| await waitForStable(WAIT_LONG_MS); | ||
| await milestone('six-column-table', 'Both tables should fill page width with proportional columns'); | ||
| }); | ||
| }, | ||
| }); |
44 changes: 44 additions & 0 deletions
44
devtools/visual-testing/tests/interactions/stories/tables/percent-width-table-overflow.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { defineStory } from '@superdoc-testing/helpers'; | ||
|
|
||
| const WAIT_LONG_MS = 800; | ||
|
|
||
| /** | ||
| * SD-1859: Percent-width tables should not overflow page bounds in mixed orientation docs | ||
| * | ||
| * Uses the actual document from the SD-1859 bug report: NuraBio document | ||
| * which has a percent-width table in a document with mixed portrait/landscape sections. | ||
| * Before the fix, the table overflowed the right edge of portrait pages because | ||
| * column widths were computed using landscape dimensions but rendered in portrait. | ||
| * After the fix, column widths are rescaled to fit the current page's content area. | ||
| */ | ||
| export default defineStory({ | ||
| name: 'percent-width-table-overflow', | ||
| description: 'SD-1859: Percent-width tables should fit within portrait page bounds', | ||
| tickets: ['SD-1859'], | ||
| startDocument: 'tables/SD-1859-mixed-orientation.docx', | ||
| layout: true, | ||
| hideCaret: true, | ||
| hideSelection: true, | ||
|
|
||
| async run(page, helpers): Promise<void> { | ||
| const { step, waitForStable, milestone } = helpers; | ||
|
|
||
| await step('Wait for document to load', async () => { | ||
| await page.waitForSelector('.superdoc-page', { timeout: 30_000 }); | ||
| await waitForStable(WAIT_LONG_MS); | ||
| await milestone('page1-table', 'Page 1 table should fit within page bounds'); | ||
| }); | ||
|
|
||
| await step('Scroll to see the table on page 2', async () => { | ||
| await page.evaluate(() => { | ||
| const container = document.querySelector('.harness-main'); | ||
| const scrollTarget = container?.querySelector('.superdoc-page:nth-child(2)'); | ||
| if (scrollTarget) { | ||
| scrollTarget.scrollIntoView({ block: 'start' }); | ||
| } | ||
| }); | ||
| await waitForStable(WAIT_LONG_MS); | ||
| await milestone('page2-table', 'Table should not overflow right edge of portrait page'); | ||
| }); | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.