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

fix(link): ensure Icon in component has inline display property to respect dimensions of the parent #6349

Merged
merged 2 commits into from
Oct 24, 2023

Conversation

tomdavies73
Copy link
Contributor

@tomdavies73 tomdavies73 commented Oct 5, 2023

fix #6295

Proposed behaviour

Screenshot 2023-10-05 at 14 55 58

All elements which are children of anchor elements in Link have the inline-block display property applied. However, due to our new Icon font sizes this now causes Icons to not respect the dimensions of parent containers.

To mitigate this we've set display to inline instead when Links are rendered with no children and an Icon, ensuring the parents dimensions are properly respected.

Current behaviour

Screenshot 2023-10-05 at 14 56 19

All elements which are children of anchor elements in Link have the inline-block display property applied, causing a visual bug where Icons do not properly respect the dimensions of their parent containers

Checklist

  • Commits follow our style guide
  • Related issues linked in commit messages if required
  • Screenshots are included in the PR if useful
  • All themes are supported if required
  • Unit tests added or updated if required
  • Cypress automation tests added or updated if required
  • Playwright automation tests added or updated if required
  • Storybook added or updated if required
  • Translations added or updated (including creating or amending translation keys table in storybook) if required
  • Typescript d.ts file added or updated if required
  • Related docs have been updated if required

QA

  • Tested in CodeSandbox/storybook
  • Add new Cypress test coverage if required
  • Carbon implementation matches Design System/designs
  • UI Tests GitHub check reviewed if required

Additional context

Testing instructions

The following CodeSandbox is an example of the broken behaviour.
You can see the new behaviour by looking at the version in the comment by codesandbox[bot].

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 5, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 5b0d61e:

Sandbox Source
carbon-quickstart Configuration
carbon-quickstart-typescript Configuration
carbon-quickstart PR
tender-napier-wfnv29 Issue #6295

@tomdavies73 tomdavies73 marked this pull request as draft October 5, 2023 13:58
@tomdavies73 tomdavies73 force-pushed the FE-6197 branch 2 times, most recently from b215da6 to 03cbe15 Compare October 6, 2023 10:00
@Parsium Parsium self-requested a review October 6, 2023 12:34
@@ -72,6 +73,18 @@ context("Test for Link component", () => {
tooltipPreview().should("have.text", testCypress);
});

Copy link
Contributor

@Parsium Parsium Oct 6, 2023

Choose a reason for hiding this comment

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

question: wondering if these cypress tests would be necessary here, given we are testing the same styling with jest tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, technically we could probably get away with just having unit tests, but I thought it was worth just doubling up as we've done the same for other features in Link

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't really mind if you leave both unit and CI tests in tbh. However I do think a test story so chromatic can capture it would be best

Copy link
Contributor

@edleeks87 edleeks87 left a comment

Choose a reason for hiding this comment

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

Nothing much beyond what @Parsium has commented already

Parsium
Parsium previously approved these changes Oct 12, 2023
parameters: {
info: { disable: true },
chromatic: {
disableSnapshot: true,
disableSnapshot: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

This will mean chromatic captures both the DefaultStory and FlexContainer stories. If that's not what you intended I think revert this and set the parameters directly on the FlexContainer story.

FlexContainer.parameters = { chromatic: { disableSnapshot: false }};

…spect dimensions of the parent

all children of anchor elements in `Link` have the inline-block display property applied.
However due to our new `Icon` font sizes this now causes `Icon`s to not respect the dimensions
of parent containers. To mitigate this we've set display to inline instead when `Link`s are
rendered with no children and an `Icon`, ensuring the parents dimensions are properly respected

fix #6295
@edleeks87 edleeks87 marked this pull request as ready for review October 16, 2023 13:03
@tomdavies73 tomdavies73 merged commit 2e28d11 into master Oct 24, 2023
15 checks passed
@tomdavies73 tomdavies73 deleted the FE-6197 branch October 24, 2023 09:32
@carbonci
Copy link
Collaborator

🎉 This PR is included in version 122.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Link: without text the icon is not well align
6 participants