Skip to content

chore: Fix downstream build failures introduced by #4514#4566

Draft
at-susie wants to merge 14 commits into
mainfrom
fix/icon-size
Draft

chore: Fix downstream build failures introduced by #4514#4566
at-susie wants to merge 14 commits into
mainfrom
fix/icon-size

Conversation

@at-susie
Copy link
Copy Markdown
Member

@at-susie at-susie commented May 31, 2026

Description

Fixes a compatibility issue that caused a downstream package build to fail after #4514 added size and strokeWidth props to IconProvider.

When the IconProvider context is not present, sizeOverrides and strokeWidthOverrides can be undefined, causing computeSizeOverrides to crash with TypeError: Cannot read properties of undefined. To fix this, I added a null guard that returns early when either map is undefined.

Related links, issue #, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Comment thread src/icon/internal.tsx Outdated
Comment thread src/icon/mixins.scss Outdated
Comment thread src/icon/internal.tsx Outdated
Comment on lines +83 to +85
if (!sizeOverrides || !strokeWidthOverrides) {
return result;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it expected that it will return an empty object for when either sizeOverrides or strokeWidthOverrides is undefined? Maybe this should be something like

Suggested change
if (!sizeOverrides || !strokeWidthOverrides) {
return result;
}
if (!sizeOverrides) {
sizeOverrides = {};
}
if (!strokeWidthOverrides) {
strokeWidthOverrides = {};
}

instead. This way, when sizeOverrides is not defined, the strokeWidthOverrides will still be applied (and vice-versa).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's better. Integrated your suggestion

@at-susie at-susie requested a review from SpyZzey June 1, 2026 08:51
@at-susie at-susie marked this pull request as ready for review June 1, 2026 08:52
@at-susie at-susie requested a review from a team as a code owner June 1, 2026 08:52
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.42%. Comparing base (3215fea) to head (203d2d4).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/icon/internal.tsx 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4566      +/-   ##
==========================================
- Coverage   97.43%   97.42%   -0.01%     
==========================================
  Files         941      941              
  Lines       29725    29731       +6     
  Branches    10803    10805       +2     
==========================================
+ Hits        28962    28966       +4     
- Misses        756      758       +2     
  Partials        7        7              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

describe('missing context fields (null guard)', () => {
it('renders without crashing when no IconProvider is present', () => {
const { container } = render(<Icon name="calendar" size="normal" />);
expect(container.querySelector('[class*="icon"]')).not.toBeNull();
Copy link
Copy Markdown
Member

@SpyZzey SpyZzey Jun 1, 2026

Choose a reason for hiding this comment

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

Can we use the Cloudscape test utils here? e.g.,

const wrapper = createWrapper(container)
wrapper.findIcon()

So that we don't depend on internals.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call. Updated to use expect(wrapper(container).findIcon())

<Icon name="calendar" size="normal" />
</IconProvider>
);
const iconEl = container.querySelector('[class*="icon"]') as HTMLElement;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call. Updated

@at-susie at-susie requested review from a team and NathanZlion and removed request for a team June 1, 2026 10:41
<Icon name="calendar" size="normal" />
</IconProvider>
);
const iconEl = container.querySelector('[class*="icon"]') as HTMLElement;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and same here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call. Updated

Comment thread src/icon/internal.tsx
}): SizeOverrideResult {
const result: SizeOverrideResult = {};

if (!sizeOverrides) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why can sizeOverrides and strokeWidthOverrides be undefined in the first place if they are required in the function signature?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point. Updated the parameter types to | undefined to make this explicit.

@at-susie at-susie removed the request for review from NathanZlion June 1, 2026 10:46
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.

3 participants