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(Pageheader,Tearsheet,Notifications): resolves CSP violations #6340

Conversation

AlexanderMelox
Copy link
Contributor

Closes #6190

This PR resolves CSP violation issues

What did you change?

Moved inline styles to useIsomorphicEffect

How did you test and verify your work?

Storybook

Copy link

netlify bot commented Oct 31, 2024

Deploy Preview for ibm-products-web-components ready!

Name Link
🔨 Latest commit ab8da41
🔍 Latest deploy log https://app.netlify.com/sites/ibm-products-web-components/deploys/678671eb8d277f000871e812
😎 Deploy Preview https://deploy-preview-6340--ibm-products-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 31, 2024

Deploy Preview for carbon-for-ibm-products ready!

Name Link
🔨 Latest commit ab8da41
🔍 Latest deploy log https://app.netlify.com/sites/carbon-for-ibm-products/deploys/678671eb9141c9000885dbe6
😎 Deploy Preview https://deploy-preview-6340--carbon-for-ibm-products.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@AlexanderMelox AlexanderMelox changed the title 6190 csp spreadsheet tearsheet notifications page header fix(Pageheader,Tearsheet,Notifications): resolves CSP violations Oct 31, 2024
@AlexanderMelox AlexanderMelox marked this pull request as draft October 31, 2024 18:07
@AlexanderMelox AlexanderMelox marked this pull request as ready for review November 1, 2024 16:58
@AlexanderMelox
Copy link
Contributor Author

Screenshot 2024-11-01 at 1 00 55 PM Everything is good, just having issues getting this TS type error

@matthewgallo
Copy link
Member

matthewgallo commented Nov 1, 2024

I think I found a way to work around this with the following added to page header:

interface HTMLElementStyled extends HTMLElement {
  style: CSSStyleDeclaration;
}
const headerRef = (ref || localHeaderRef) as MutableRefObject<HTMLElementStyled>;

I just extended HTMLElement because when using it directly, I kept getting this read only error. Ideally you could just use HTMLSectionElement since the ref is being passed to a <section> but that doesn't exist 😱
image

@AlexanderMelox
Copy link
Contributor Author

Interesting, thank you! Matt to the rescue 🛟

davidmenendez
davidmenendez previously approved these changes Jan 10, 2025
@@ -31,7 +31,7 @@ import {
Copy,
ErrorFilled,
CheckmarkFilled,
} from '@carbon/react/icons';
} from '@carbon/icons-react';
Copy link
Member

Choose a reason for hiding this comment

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

Not sure about this change? All icons should now be imported from @carbon/react/icons

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was giving me a build error and somehow changing the import fixes it

Copy link
Member

Choose a reason for hiding this comment

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

Can you share what the error was?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2025-01-09 at 11 41 16 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When importing from @carbon/icons-react it fixes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We had a convo with Carbon core a while back and I don't know where we landed with this, FYI @tay1orjones

Copy link
Member

@matthewgallo matthewgallo left a comment

Choose a reason for hiding this comment

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

Lets see if we can import icons from @carbon/react/icons, also the styles in the page header seem to have been affected by these changes
Screenshot 2025-01-10 at 10 59 11 AM

@AlexanderMelox
Copy link
Contributor Author

@matthewgallo fixed page header styles !

@matthewgallo
Copy link
Member

Sorry, one more style change! I just noticed that the entrance animation for the notification panel is also missing with the current changes.

Copy link
Member

@matthewgallo matthewgallo left a comment

Choose a reason for hiding this comment

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

Just spotted one more style change in the stacked tearsheets that looks unintended.

@AlexanderMelox
Copy link
Contributor Author

Just spotted one more style change in the stacked tearsheets that looks unintended.

I see its the same issue when using CSS properties, nice catch

@AlexanderMelox
Copy link
Contributor Author

@matthewgallo fixed, i assume it was the size of the tearsheet?

Before:
Screenshot 2025-01-13 at 5 12 03 PM

After:
Screenshot 2025-01-13 at 5 12 33 PM

@matthewgallo matthewgallo added this pull request to the merge queue Jan 14, 2025
Merged via the queue into carbon-design-system:main with commit 4e11b90 Jan 14, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest https://hacktoberfest.com/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Address CSP issues in notifications, page header, tearsheet
4 participants