Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap Icon component's SVG in a div to fix Safari rendering issue #931

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

joshfarrant
Copy link
Contributor

@joshfarrant joshfarrant commented Feb 27, 2025

Summary

Fixes an issue where the edges of an Icon component's rendered SVG would be cut off in Safari.

List of notable changes:

  • Wraps the rendered SVG in a div
  • Applies styling to wrapper component, rather than directly to the SVG

What should reviewers focus on?

  • Take a look at the docs/storybook to make sure I've not broken any styling

Supporting resources (related issues, external links, etc):

Contributor checklist:

  • All new and existing CI checks pass
  • Tests prove that the feature works and covers both happy and unhappy paths
  • Any drop in coverage, breaking changes or regressions have been documented above
  • UI Changes contain new visual snapshots (generated by adding update snapshots label to the PR)
  • All developer debugging and non-functional logging has been removed
  • Related issues have been referenced in the PR description

Reviewer checklist:

  • Check that pull request and proposed changes adhere to our contribution guidelines and code of conduct
  • Check that tests prove the feature works and covers both happy and unhappy paths
  • Check that there aren't other open Pull Requests for the same update/change

Screenshots:

Before After

image

image

Copy link

changeset-bot bot commented Feb 27, 2025

🦋 Changeset detected

Latest commit: dd80e4f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@primer/react-brand Patch
@primer/brand-primitives Patch
@primer/brand-e2e Patch
@primer/brand-fonts Patch
@primer/brand-config Patch
@primer/brand-storybook Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Feb 27, 2025

🟢 No design token changes found

Copy link
Contributor

github-actions bot commented Feb 27, 2025

🟢 No visual differences found

Our visual comparison tests did not find any differences in the UI.

@joshfarrant joshfarrant changed the title Wrap Icon component in a div to fix Safari rendering issue Wrap Icon component's SVG in a div to fix Safari rendering issue Feb 27, 2025
@joshfarrant joshfarrant marked this pull request as ready for review February 27, 2025 10:32

Choose a reason for hiding this comment

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

PR Overview

This PR fixes a Safari rendering issue where the edges of the Icon component's SVG were being cut off. Key changes include:

  • Wrapping the rendered SVG with a div.
  • Moving styling from the SVG to the wrapper.
  • Updating tests to account for the new wrapper element.

Reviewed Changes

File Description
.changeset/grumpy-countries-fail.md Adds a changeset documenting the Safari rendering bug fix.
packages/react/src/Icon/Icon.tsx Refactors Icon component to wrap the SVG in a div and update styling usage.
packages/react/src/Icon/Icon.test.tsx Modifies tests to verify className propagation on the new wrapper element.

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this bug only happening in Safari? The old snapshot, which isn't rendered in Safari, shows a cut-off icon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 [BUG] - Icon in Card component with cut off edges
2 participants