Skip to content

fix(ui-core): drop Typography's block wrapper for span and div - #32068

Merged
chirag-madlani merged 4 commits into
mainfrom
fix/core-typography-prose-wrapper
Sep 18, 2026
Merged

chirag-madlani merged 4 commits into
mainfrom
fix/core-typography-prose-wrapper

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Typography wraps its element in a block-level <div class="prose">. For span and div that wrapper contributes nothing but a box — and costs correctness.

Why the wrapper is load-bearing sometimes

styles/typography.css applies its real rules through a descendant selector (.prose :not(...)), and every rule inside is gated on an element type — p, h1-h6, ol, ul, li, blockquote, a, code, pre, img, figure, table elements. For those the wrapper has to stay: moving prose onto the element would stop the rule matching and, say, a p would silently lose its margins.

span and div are targeted by no such rule. For them the wrapper only contributes the element-level .prose layer — --tw-prose-* vars plus color, font-size, line-height, all inherited properties. Putting prose directly on the element gives an identical computed style on the text, while dropping a block-level <div> that breaks inline flow and produces invalid <div>-inside-<span> nesting when Typography is nested.

Decided from the element type, not a flag

#33021 landed an inline prop for the same problem while this PR was open. This replaces it, and removes inline.

The reason is not just taste. inline was unconditional, so passing it next to ellipsis or a non-default quoteVariant silently dropped a wrapper those genuinely need — ellipsis carries its truncation classes there, and a quote variant styles content through .prose.prose-*-quote :not(...), another descendant selector. The call site has to know a rule it can't see.

Deciding inside the component makes that unrepresentable:

const canUnwrap =
  !isEllipsis && quoteVariant === 'default' && UNWRAPPED_ELEMENTS.has(Component);

UNWRAPPED_ELEMENTS is a deliberately small allowlist (span, div); anything not listed keeps the wrapper.

Breaking change: inline is removed. It shipped 2 days ago in #33021 and its only consumers were 8 call sites in filter-select, all default as="span" — updated here, and they behave identically because the allowlist covers them. No other consumer in this repo or in Collate uses it.

Also

Widens the anchor pass-through typing (href / target / rel) for the as="a" shape used by antd Typography.Link migrations. These were already spread onto Component at runtime; this only makes the type match existing behaviour.

Verification

  • 320/320 core-component tests pass; tsc clean; ui-checkstyle a clean no-op.
  • Tests cover both directions: span/div render unwrapped and carry prose themselves, while p/h1/a/blockquote/li, ellipsis, and a non-default quote variant all keep the wrapper.

🤖 Generated with Claude Code

RetriggerConfidence Score: 4/5

The PR is not yet safe to merge because existing not-prose Typography consumers lose inherited prose line-height after being unwrapped.

Findings

  1. P1 not-prose disables typography styles ▶
Summary

The PR conditionally removes Typography’s wrapper for span and div, while retaining it for ellipsis, quote variants, and elements requiring descendant prose selectors.

  • Removes the recently introduced inline prop and updates filter-select consumers.
  • Adds anchor pass-through types and wrapper-behavior tests.
  • Updates stories and dependent tests for the new DOM structure.

Reviews (8) · Last reviewed commit: "fix(ui-core): restore the anchor typing,..."

Copilot AI lite review requested due to automatic review settings August 25, 2026 18:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Aug 25, 2026
if (canUnwrap) {
return (
<Component
{...otherProps}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 not-prose disables typography styles

When an unwrapped span or div consumer supplies not-prose, the element receives both prose and not-prose, so the element-level prose selector no longer matches. Existing FieldCard names and descriptions therefore lose the wrapper’s 20px line-height, changing their visible vertical spacing.

@github-actions

github-actions Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 72%
72.9% (102378/140434) 57.88% (62343/107698) 58.92% (20367/34565)

@github-actions

github-actions Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 1ca3946daa223d35d222dc6684a60a367d898e75 in Playwright run 35345927879, attempt 1.

✅ 738 passed · ❌ 0 failed · 🟡 1 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 34m 6s

⏱️ Max setup 6m 18s · max shard execution 17m 13s · max shard-job elapsed before upload 20m 43s · reporting 5s

🌐 177.61 requests/attempt · 1.70 app boots/UI scenario · 36.88% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 36.88% (convergence target: at most 15%).
  • Application boot ratio was 1.7 per UI scenario (1266 boots / 743 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 156 0 0 0 0 0
✅ Shard chromium-02 164 0 0 0 0 0
✅ Shard chromium-03 171 0 0 0 0 0
🟡 Shard chromium-04 159 0 1 0 0 0
✅ Shard global-state-01 11 0 0 0 0 0
✅ Shard import-export-01 7 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 28 0 0 0 0 0
✅ Shard search-01 12 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0
🟡 1 flaky test(s) (passed on retry)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard chromium-04, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

Copilot AI review requested due to automatic review settings August 26, 2026 05:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-08-27T08:31:55Z)

Blocked the queue: playwright-summary

@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — manual (2026-08-31T05:46:55Z)

The entry left the queue before it was built, so no checks ran against it.

Typography wraps its content in a block-level `<div className="prose">`
regardless of the `as` prop. Every inline usage therefore renders as a block
element - text meant to sit mid-sentence takes its own line - and nesting one
Typography inside another emits a `<div>` inside a `<span>`, which is invalid
DOM and trips React's validateDOMNesting.

`styles/typography.css` applies its real rules through a *descendant* selector
(`.prose :not(...)`), and every rule in that block is gated on an element type:
p, h1-h6, ol, ul, li, blockquote, a, code, pre, img, figure, table. For those
the wrapper is load-bearing - moving `prose` onto the element itself would stop
the rule matching and a `p` would silently lose its margins.

`span` and `div` are targeted by no such rule. There the wrapper contributes
only the element-level `.prose` layer - the `--tw-prose-*` vars plus `color`,
`font-size` and `line-height`, all inherited properties - so setting `prose`
directly on the element produces an identical computed style on the text while
dropping the spurious block box.

Render the element directly in that case. Ellipsis keeps the wrapper (it
carries the truncation classes) and so does a non-default quote variant, which
is also styled through a descendant selector. Deliberately a small allowlist:
anything unlisted is unchanged.

One test updated: ExploreQueryFilterChips asserted the *parent* carried
`prose`, which encoded the wrapper as contract.

Verified against main: 1222 suites / 14501 tests pass. The two remaining
failures (CronUtils, ServiceConnectionUtils) fail identically on main without
this change.
Two story names described the old model and are now wrong: "as prop — wraps
children in inner element" and "as prop with className on inner element" both
imply an outer wrapper that `span`/`div` no longer get.

Documents the actual contract on the meta block - which elements keep the
`.prose` wrapper and why - and adds two stories:

- **DOM structure** — `span`/`div` render bare with `prose` on the element,
  while `p` and the other prose-targeted elements keep the wrapper so the
  descendant rules still match. Ellipsis keeps it too, to have somewhere to
  clip.
- **Inline flow** — the reason the wrapper had to go: a block-level wrapper
  pushes each Typography onto its own line, breaking any sentence that mixes
  plain text with emphasised fragments.

Storybook builds clean; eslint and prettier pass.
The two new stories had JSX lines over 80 columns. `ui-checkstyle` runs
`prettier --write` on changed files and fails when the working tree comes back
dirty, so this is a gate failure rather than a cosmetic nit.

No behavioural change - line wrapping only.
… test

Two CI failures from the rebase:

- `href` / `target` / `rel` were lost resolving the props-interface
  conflict — main's side won and took them with it, leaving the
  `HTMLAttributeAnchorTarget` import orphaned. eslint caught it as an
  unused import; the real damage was the missing typing. Restored.

- ContextCenterSubNavSections asserted on `.prose > span`, the shape
  from before the wrapper was dropped. A span now carries `prose`
  itself, so the heading is a direct child. The selector was coupled to
  exactly what this change alters.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@gitar-bot

gitar-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 closed / 1 findings

🟡 Medium risk

Refactors Typography to drop the block-level wrapper for span and div elements, eliminating unnecessary nesting while preserving the wrapper for elements that rely on descendant selectors (like p, headings, lists). Removes the inline prop introduced in #33021 and updates all call sites; decides wrapper behavior internally based on element type and options, making the logic unambiguous and preventing silent style loss. All 320 core-component tests pass with coverage for both wrapped and unwrapped cases.

✅ 1 closed
✅ Quality: Unused type import HTMLAttributeAnchorTarget

📄 openmetadata-ui-core-components/src/main/resources/ui/src/components/foundations/typography.tsx:16-22
This commit adds HTMLAttributeAnchorTarget to the type import block, but the symbol is not referenced anywhere in typography.tsx (the only occurrence is the import itself). An unused import trips @typescript-eslint/no-unused-vars / TypeScript noUnusedLocals and will fail lint/CI. Remove it from the import list.

Review coverage

Rules No rules evaluated

Functional validation Not enabled · Set up

Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants