Skip to content

Commit

Permalink
fix: Add context id to Box
Browse files Browse the repository at this point in the history
  • Loading branch information
Al-Dani committed Jul 26, 2023
1 parent 41ed94d commit a5c1d7c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/box/internal.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React from 'react';
import React, { useContext } from 'react';
import { getBaseProps } from '../internal/base-component';
import clsx from 'clsx';
import styles from './styles.css.js';
import { BoxProps } from './interfaces';
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
import { ScrollbarLabelContext } from '../internal/context/scrollbar-label-context';

type InternalBoxProps = BoxProps & InternalBaseComponentProps;

Expand All @@ -24,7 +25,12 @@ export default function InternalBox({
__internalRootRef = null,
...props
}: InternalBoxProps) {
const baseProps = getBaseProps(props);
const wrapperHeadingId = useContext(ScrollbarLabelContext);
const elementId = props.id ?? wrapperHeadingId;
const baseProps = getBaseProps({
...props,
id: elementId,
});
const marginsClassNamesSuffices = getClassNamesSuffixes(margin);
const paddingsClassNamesSuffices = getClassNamesSuffixes(padding);
// This can be any arbitrary string if passed into tagOverride.
Expand Down

0 comments on commit a5c1d7c

Please sign in to comment.