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

feat: added CSP nonce prop #2728

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .yarn/versions/dd1eb89d.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
releases:
"@radix-ui/react-scroll-area": patch
"@radix-ui/react-select": patch

declined:
- primitives
7 changes: 5 additions & 2 deletions packages/react/scroll-area/src/ScrollArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,13 @@ ScrollArea.displayName = SCROLL_AREA_NAME;
const VIEWPORT_NAME = 'ScrollAreaViewport';

type ScrollAreaViewportElement = React.ElementRef<typeof Primitive.div>;
interface ScrollAreaViewportProps extends PrimitiveDivProps {}
interface ScrollAreaViewportProps extends PrimitiveDivProps {
nonce?: string;
}

const ScrollAreaViewport = React.forwardRef<ScrollAreaViewportElement, ScrollAreaViewportProps>(
(props: ScopedProps<ScrollAreaViewportProps>, forwardedRef) => {
const { __scopeScrollArea, children, ...viewportProps } = props;
const { __scopeScrollArea, children, nonce, ...viewportProps } = props;
const context = useScrollAreaContext(VIEWPORT_NAME, __scopeScrollArea);
const ref = React.useRef<ScrollAreaViewportElement>(null);
const composedRefs = useComposedRefs(forwardedRef, ref, context.onViewportChange);
Expand All @@ -151,6 +153,7 @@ const ScrollAreaViewport = React.forwardRef<ScrollAreaViewportElement, ScrollAre
dangerouslySetInnerHTML={{
__html: `[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`,
}}
nonce={nonce}
/>
<Primitive.div
data-radix-scroll-area-viewport=""
Expand Down
7 changes: 5 additions & 2 deletions packages/react/select/src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1037,11 +1037,13 @@ const VIEWPORT_NAME = 'SelectViewport';

type SelectViewportElement = React.ElementRef<typeof Primitive.div>;
type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
interface SelectViewportProps extends PrimitiveDivProps {}
interface SelectViewportProps extends PrimitiveDivProps {
nonce?: string;
}

const SelectViewport = React.forwardRef<SelectViewportElement, SelectViewportProps>(
(props: ScopedProps<SelectViewportProps>, forwardedRef) => {
const { __scopeSelect, ...viewportProps } = props;
const { __scopeSelect, nonce, ...viewportProps } = props;
const contentContext = useSelectContentContext(VIEWPORT_NAME, __scopeSelect);
const viewportContext = useSelectViewportContext(VIEWPORT_NAME, __scopeSelect);
const composedRefs = useComposedRefs(forwardedRef, contentContext.onViewportChange);
Expand All @@ -1053,6 +1055,7 @@ const SelectViewport = React.forwardRef<SelectViewportElement, SelectViewportPro
dangerouslySetInnerHTML={{
__html: `[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`,
}}
nonce={nonce}
/>
<Collection.Slot scope={__scopeSelect}>
<Primitive.div
Expand Down
Loading