Repository navigation
fix(atomic-wind): add fallback size to icon SVG - #3179
Open
faisalahammad wants to merge 1 commit into
Open
faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
The built-in icon SVG had no width or height, so it painted at the browser default size until the Tailwind utilities arrived. On cache misses and non-singular views the CSS only lands in the footer, so icons flashed huge before snapping to their real size. Add width="1em" height="1em" presentation attributes as a fallback. Size utilities are generated with !important and still override the attributes, so final rendered sizes are unchanged. Custom SVGs keep their own dimensions. Fixes Codeinwp#3129
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #3129.
Summary
The built-in Atomic Wind icon SVG was rendered with a
viewBoxbut nowidth/height. Until the Tailwind utility CSS arrives, the browser paints it at the default replaced-element size (measured around 1264x1264 unstyled), then snaps down once the utilities apply. On cache misses (every page save clears the cached CSS) and on archive views the CSS only lands in the footer, so the flash shows up on normal page loads.This adds
width="1em" height="1em"presentation attributes to the built-in icon SVG as a fallback. They are the weakest sizing signal in the cascade: thesize-*utilities are generated with!importantand still override them, so final rendered sizes are unchanged. The custom SVG branch is untouched and keeps its own dimensions.Screenshots
No steady-state visual change. The fix only affects the first paint before the utility CSS loads.
Test instructions
npm ci && composer install && npm run build && npm run env:start(site at http://localhost:8888, admin/password).width="1em" height="1em"next to theviewBox.width="32" height="32": it still renders at 32x32 and keeps its own attributes, no1emadded.Automated: full PHPUnit suite passes (819 tests, 3577 assertions), including two new tests covering the fallback attributes and the custom SVG branch.
npm run test:unit, phpcs and phpstan are clean.Known trade-off: a hand-written single-axis utility on an icon (e.g.
w-8with no height utility) now renders 1em tall instead of the aspect-derived square it had before. All shipped patterns usesize-*(both axes), and the base CSS alternative proposed in the issue has the same behavior.Checklist before the final review