diff --git a/changelog.d/1917-icon-guard.md b/changelog.d/1917-icon-guard.md new file mode 100644 index 0000000000..a9576b82d0 --- /dev/null +++ b/changelog.d/1917-icon-guard.md @@ -0,0 +1,3 @@ +- Icons keep their glyph when a stylesheet brings jQuery UI's `.ui-icon` + rule into the page, as some browser extensions do on every site: it pushed + each icon out of its box, leaving empty buttons (Sameh Khamis, @samehkhamis, #1917). diff --git a/src/ui/styles/iconGuard.test.mjs b/src/ui/styles/iconGuard.test.mjs new file mode 100644 index 0000000000..e59f5a329b --- /dev/null +++ b/src/ui/styles/iconGuard.test.mjs @@ -0,0 +1,21 @@ +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; +import test from 'node:test'; + +const kit = readFileSync(new URL('./kit.css', import.meta.url), 'utf8').replace( + /\/\*[\s\S]*?\*\//g, + '', +); + +test("an icon's glyph stays in its box under a page-wide jQuery UI .ui-icon rule", () => { + const rule = kit.match(/\.ui-icon\.ui-icon\s*\{([^}]*)\}/); + assert.ok(rule, 'a doubled class outranks a single-class .ui-icon rule'); + for (const declaration of [ + /text-indent:\s*0/, + /overflow:\s*visible/, + /background-image:\s*none/, + /width:\s*auto/, + /height:\s*auto/, + ]) + assert.match(rule[1], declaration); +}); diff --git a/src/ui/styles/kit.css b/src/ui/styles/kit.css index 0f1622c793..1e53e8c039 100644 --- a/src/ui/styles/kit.css +++ b/src/ui/styles/kit.css @@ -40,6 +40,18 @@ user-select: none; } +/* The icon is a font ligature; `ui-icon` is also jQuery UI's sprite-icon class, and a stylesheet + that brings jQuery UI's rule into the page (some browser extensions inject it everywhere) pushes + the glyph out of its box (`text-indent: -99999px`, `overflow: hidden`, a 16 px box). The doubled + class outranks that rule and sets only what the kit never sets elsewhere. */ +.ui-icon.ui-icon { + text-indent: 0; + overflow: visible; + background-image: none; + width: auto; + height: auto; +} + .ui-tooltip { position: relative; display: inline-flex;