-
Notifications
You must be signed in to change notification settings - Fork 145
fix(painter-dom): honor appearance:hidden on inline SDTs (SD-3110) #3293
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
caio-pizzol
merged 5 commits into
main
from
caio-pizzol/SD-3110-honor-hidden-appearance-on-inline-sdt
May 14, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
408b268
fix(painter-dom): honor appearance:hidden on inline SDTs (SD-3110)
caio-pizzol 52fff7b
test(behavior): cover hidden-appearance inline SDT (SD-3110)
caio-pizzol 754b02d
fix(painter-dom): keep hidden inline SDTs out of lock-hover styling (…
caio-pizzol 3ac7c40
Merge branch 'main' into caio-pizzol/SD-3110-honor-hidden-appearance-…
caio-pizzol 265751e
fix(painter-dom): restore viewing-mode hover suppression on inline SD…
caio-pizzol 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
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
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
Binary file added
BIN
+10.2 KB
tests/behavior/tests/sdt/fixtures/sd-3110-inline-sdt-appearance-variants.docx
Binary file not shown.
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,138 @@ | ||
| import { fileURLToPath } from 'node:url'; | ||
| import path from 'node:path'; | ||
| import { test, expect } from '../../fixtures/superdoc.js'; | ||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
| const DOC_PATH = path.resolve(__dirname, 'fixtures/sd-3110-inline-sdt-appearance-variants.docx'); | ||
|
|
||
| test.use({ config: { toolbar: 'full', showSelection: true } }); | ||
|
|
||
| // The fixture has five paragraphs; we keep the wrapper-by-sdtId mapping | ||
| // explicit because it's the contract this spec asserts against. | ||
| const HIDDEN_IDS = ['1001', '1004', '1005'] as const; | ||
| const VISIBLE_IDS = ['1002', '1003'] as const; // boundingBox + omitted (default) | ||
| const HIDDEN_ALIAS_CANARIES = [ | ||
| 'HIDDEN_ALIAS_LEAK_CANARY', | ||
| 'HIDDEN_ALIAS_DOUBLE_A', | ||
| 'HIDDEN_ALIAS_DOUBLE_B', | ||
| ] as const; | ||
|
|
||
| const INLINE_SDT = '.superdoc-structured-content-inline'; | ||
| const INLINE_LABEL = '.superdoc-structured-content-inline__label'; | ||
|
|
||
| test.describe('inline SDT appearance=hidden (SD-3110)', () => { | ||
| test.beforeEach(async ({ superdoc }) => { | ||
| await superdoc.loadDocument(DOC_PATH); | ||
| await superdoc.waitForStable(); | ||
| }); | ||
|
|
||
| test('hidden wrappers carry data-appearance="hidden" and visible ones do not', async ({ superdoc }) => { | ||
| const attrs = await superdoc.page.evaluate((sel) => { | ||
| return Array.from(document.querySelectorAll(sel)).map((el) => ({ | ||
| sdtId: (el as HTMLElement).dataset.sdtId ?? null, | ||
| appearance: (el as HTMLElement).dataset.appearance ?? null, | ||
| })); | ||
| }, INLINE_SDT); | ||
|
|
||
| const byId = new Map(attrs.map((a) => [a.sdtId, a.appearance])); | ||
| for (const id of HIDDEN_IDS) expect(byId.get(id)).toBe('hidden'); | ||
| for (const id of VISIBLE_IDS) expect(byId.get(id)).toBeNull(); | ||
| }); | ||
|
|
||
| test('hidden wrappers have no alias label child; visible wrappers do', async ({ superdoc }) => { | ||
| const labelPresence = await superdoc.page.evaluate( | ||
| ({ sel, labelSel }) => { | ||
| return Array.from(document.querySelectorAll(sel)).map((el) => ({ | ||
| sdtId: (el as HTMLElement).dataset.sdtId ?? null, | ||
| hasLabel: !!el.querySelector(labelSel), | ||
| })); | ||
| }, | ||
| { sel: INLINE_SDT, labelSel: INLINE_LABEL }, | ||
| ); | ||
|
|
||
| const byId = new Map(labelPresence.map((a) => [a.sdtId, a.hasLabel])); | ||
| for (const id of HIDDEN_IDS) expect(byId.get(id)).toBe(false); | ||
| for (const id of VISIBLE_IDS) expect(byId.get(id)).toBe(true); | ||
| }); | ||
|
|
||
| test('hidden wrappers omit the alias canary from textContent', async ({ superdoc }) => { | ||
| const textByIdRaw = await superdoc.page.evaluate((sel) => { | ||
| return Array.from(document.querySelectorAll(sel)).map((el) => ({ | ||
| sdtId: (el as HTMLElement).dataset.sdtId ?? null, | ||
| text: el.textContent ?? '', | ||
| })); | ||
| }, INLINE_SDT); | ||
| const textById = new Map(textByIdRaw.map((a) => [a.sdtId, a.text])); | ||
|
|
||
| expect(textById.get('1001')).toBe('Alpha Corp v. SEC'); | ||
| expect(textById.get('1004')).toBe('first hidden span'); | ||
| expect(textById.get('1005')).toBe('second hidden span'); | ||
|
|
||
| // Visible wrappers still surface the alias as a label — that's the | ||
| // pre-existing boundingBox/default behavior. | ||
| expect(textById.get('1002')).toContain('VISIBLE_ALIAS_FOR_COMPARISON'); | ||
| expect(textById.get('1003')).toContain('DEFAULT_APPEARANCE_ALIAS'); | ||
| }); | ||
|
|
||
| test('no hidden-SDT alias canary appears anywhere in the painted layout', async ({ superdoc }) => { | ||
| const layoutText = await superdoc.page.evaluate(() => { | ||
| // .presentation-editor__pages is the painter-dom root; selection, | ||
| // copy, and visual reads operate on it. | ||
| const root = | ||
| document.querySelector('.presentation-editor__pages') ?? | ||
| document.querySelector('.superdoc-layout'); | ||
| return root?.textContent ?? ''; | ||
| }); | ||
|
|
||
| for (const canary of HIDDEN_ALIAS_CANARIES) { | ||
| expect(layoutText).not.toContain(canary); | ||
| } | ||
| }); | ||
|
|
||
| test('hovering a hidden wrapper does not paint the lock-hover background or boost z-index', async ({ superdoc }) => { | ||
| // Regression guard for the CSS specificity bug caught in PR review: | ||
| // the lock-hover rule | ||
| // .superdoc-structured-content-inline[data-lock-mode]:hover:not(.ProseMirror-selectednode) | ||
| // has (0,4,0) specificity vs (0,3,0) for the hidden-appearance hover | ||
| // rule, so without an explicit :not([data-appearance='hidden']) it | ||
| // re-introduces the lock-hover blue background + z-index 9999999 on | ||
| // hover, contradicting "visually transparent". | ||
| // Painter may emit more than one wrapper for the same SDT when the run | ||
| // is split across lines/fragments — each fragment carries the same | ||
| // data-sdt-id. Scope to the painter class and take `.first()`: the | ||
| // CSS specificity bug is per-element, so a single wrapper is enough. | ||
| const wrapper = superdoc.page | ||
| .locator('.superdoc-structured-content-inline[data-sdt-id="1001"]') | ||
| .first(); | ||
| await wrapper.hover(); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| const styles = await wrapper.evaluate((el) => { | ||
| const cs = getComputedStyle(el); | ||
| return { backgroundColor: cs.backgroundColor, zIndex: cs.zIndex }; | ||
| }); | ||
|
|
||
| // Default backgrounds on most browsers are transparent / rgba(0, 0, 0, 0); | ||
| // the regression value is rgba(98, 155, 231, 0.08). | ||
| expect(styles.backgroundColor).not.toContain('98, 155, 231'); | ||
| // The lock-hover rule sets z-index 9999999 on top of any default — if | ||
| // it slipped through, the hidden wrapper would jump above siblings. | ||
| expect(styles.zIndex).not.toBe('9999999'); | ||
| }); | ||
|
|
||
| test('selecting a hidden wrapper copies only the wrapped phrase', async ({ superdoc }) => { | ||
| const selectionText = await superdoc.page.evaluate(() => { | ||
| const wrapper = document.querySelector('[data-sdt-id="1001"]'); | ||
| if (!wrapper) return null; | ||
| const range = document.createRange(); | ||
| range.selectNodeContents(wrapper); | ||
| const sel = window.getSelection(); | ||
| sel?.removeAllRanges(); | ||
| sel?.addRange(range); | ||
| return sel?.toString() ?? null; | ||
| }); | ||
|
|
||
| expect(selectionText).toBe('Alpha Corp v. SEC'); | ||
| expect(selectionText).not.toContain('HIDDEN_ALIAS_LEAK_CANARY'); | ||
| }); | ||
| }); |
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.