Repository navigation
Conversation
Replace the four @tailwindcss/typography margin-top resets (hr/h2/h3/h4 + *) and the editor table widget padding reset (.ProseMirror-widget + *) with keyed selectors that keep the same computed styles. Refs makeplane#9892
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to No actionable issue is established in the selector changes. Merge after normal checks. Pre-merge checks |
|
Description
Summary
This PR removes the 5 in-repo CSS rules from #9892 that end in a universal selector after a sibling combinator (
x + *). Computed styles do not change.packages/editor/src/styles/table.css:.ProseMirror-widget + *is now.ProseMirror-widget + :is(p, h1, h2, h3, h4, h5, h6, pre, [data-type="horizontalRule"], .editor-callout-component). It still sets onlypadding-top: 0 !importanton the block right after the table drag-handle widget.apps/web/styles/typography.config.ts(new, loaded with@config): it sets the typography plugin keyshr + *,h2 + *,h3 + *andh4 + *tonull, so the plugin does not emit them. It adds one keyed rule,:is(hr, h2, h3, h4) + :is(p, blockquote, ul, ol, dl, pre, table, img, video, hr, h2, h3, h4, .editor-callout-component), with the samemargin-top: 0. The plugin still wraps this rule in.prose :where(...), so its specificity does not change.apps/web/styles/globals.css: one line,@config "./typography.config.ts";, after the existing@plugin "@tailwindcss/typography";.Why
See #9892. When a stylesheet has a rule that ends in
+ *or~ *, Chromium restyles the following siblings and their subtrees on each child insert or remove. A windowed list or table inserts and removes rows on every scroll step, so it pays this cost on every frame. Selectors with element or class keys do not have this problem.Remaining
4 rules are left. They come from
@makeplane/propel0.7.3, which is an external package. Its source is not in this repo:[&>*:not(span)~*]:-ms-pxand[&>*:not(span)~*]:rounded-s-none[&>*+*]:rounded-s-noneand[&>*+*]:border-s-0The Plane team must fix these in propel. That is why this PR uses "Refs" and not "Fixes". This PR does not add row windowing.
Notes
No visual change is intended. I made the keyed lists from the elements whose computed style the old rules actually changed. I checked this in a browser (see below). Elements that are not in the lists already get the same value from other rules, for example
margin: 0 !importanton editor paragraphs and headings. If the editor adds a new block type with its own top padding or margin, it may need to be added to these lists.Type of Change
Test Scenarios
Verification
pnpm turbo run build --filter=webpasses onpreviewand on this branch.globals-*.csswith postcss and counted the rules whose selector matches[+~]\s*\*:preview: 6 rules (9 complex selectors). These are typography (4 selectors in one rule), propel (4 rules), and.ProseMirror-widget + *.p,h1toh6,hr, the horizontal rule div,blockquote, a list, a code block and a callout. It also has table cells with 0, 1 and 2 drag-handle widgets before each block type, andnot-prosecases. I rendered it in headless Chrome inside the large/regular, small and mobileeditor-containervariants. For each of the 12,069 elements, I compared margins, paddings, border, display, font size, line height and the box position and height. The production CSS frompreviewand from this branch gives 0 differences. As a control, when I only remove the old rules, the check finds differences (for exampleblockquoteand callout after a heading, and paragraphs, headings, the hr div and callouts after a table widget).oxfmt --checkpasses on the 3 changed files.oxlintpasses. The repo.oxlintrc.jsonignores*.config.ts.pnpm --filter web check:types(react-router typegen andtsc --noEmit) passes.References
Refs #9892
Summary by CodeRabbit