Skip to content

Commit d7a2558

Browse files
Hide a filling table's colgroup on a narrow page instead of overriding its widths with !important (#39)
The 48em rule gave up the columns' shares with `col { width: auto !important; }`. Hiding the colgroup drops the inline widths the same way (checked in Chromium: a 80%/20% colgroup at 600px lays out 348/235 with it, 69/514 hidden, the same as no colgroup), and a host whose stylesheets refuse !important, such as SharpMUSH's portal, can carry the rule as written. The changelog also gets the 2.11.0 heading the grow entry shipped under. Claude-Session: https://claude.ai/code/session_018eAjtsQTFqWAeWQMc7ebNo Co-authored-by: Claude <noreply@anthropic.com>
1 parent dd51634 commit d7a2558

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

99
## Unreleased
1010

11+
### Fixed
12+
13+
- **A page narrow enough to hide columns gives up their shares without `!important`.** `LayoutCss`
14+
hides a filling table's `<colgroup>` there instead of overriding each column's inline width, so a
15+
site whose stylesheets forbid `!important` can carry the rule as written.
16+
17+
## 2.11.0 — 2026-10-07
18+
1119
### Added
1220

1321
- **Tables that fill their width.** `TableColumn.Grow` gives a column a share of the width a table has

‎MarkupString.Html/LayoutCss.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ public static class LayoutCss
8787
".ms-table th { border-bottom: 1px solid var(--ms-header-rule, var(--ms-header-rule-default, currentColor)); color: var(--ms-heading, var(--ms-heading-default, inherit)); }\n" +
8888
".ms-table.ms-striped > tbody > tr:nth-child(even) { background: var(--ms-stripe, var(--ms-stripe-default, rgba(127, 127, 127, 0.12))); }\n" +
8989
".ms-table .ms-nowrap, .ms-table .ms-nowrap .ms-text { white-space: pre; overflow-wrap: normal; }\n" +
90-
"@media (max-width: 48em) { .ms-table .ms-p3 { display: none; } .ms-table.ms-fill > colgroup > col { width: auto !important; } }\n" +
90+
"@media (max-width: 48em) { .ms-table .ms-p3 { display: none; } .ms-table.ms-fill > colgroup { display: none; } }\n" +
9191
"@media (max-width: 32em) { .ms-table .ms-p2 { display: none; } }\n";
9292
}

‎MarkupString.Tests/Layout/WidgetLayoutTests.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public async Task Table_InHtml_AGrowingTableFillsThePage()
243243
await Assert.That(BlockLayout.Build(Who(), 60).Render(MarkupFormat.Html, Registry)).DoesNotContain("<colgroup>")
244244
.Because("a table that does not fill is as wide as its cells");
245245
await Assert.That(LayoutCss.Fixed).Contains(".ms-table.ms-fill { width: 100%; }");
246-
await Assert.That(LayoutCss.Fixed).Contains(".ms-table.ms-fill > colgroup > col { width: auto !important; }")
246+
await Assert.That(LayoutCss.Fixed).Contains(".ms-table.ms-fill > colgroup { display: none; }")
247247
.Because("on a page narrow enough to hide columns, their shares are given up");
248248
}
249249

0 commit comments

Comments
 (0)