diff --git a/packages/gestalt/src/List/Message.tsx b/packages/gestalt/src/List/Message.tsx index ab127a3a7f..1e8fd7845d 100644 --- a/packages/gestalt/src/List/Message.tsx +++ b/packages/gestalt/src/List/Message.tsx @@ -1,6 +1,4 @@ import { Children, cloneElement, ReactElement } from 'react'; -import { useColorScheme } from '../contexts/ColorSchemeProvider'; -import styles from '../List.css'; import Text from '../Text'; type Size = '100' | '200' | '300' | '400' | '500' | '600'; @@ -11,8 +9,6 @@ type Props = { }; export default function ListText({ size, text }: Props) { - const { colorSchemeName } = useColorScheme(); - // Flow shuold catch if text is missing. In case Flow is not enabled and text is missing, the errors are not that helpful. This surfaces the problem more explicitly. if (!text) { throw new Error(`Gestalt List is missing \`label\` prop or a \`text\` prop within List.Item.`); @@ -22,20 +18,14 @@ export default function ListText({ size, text }: Props) { return {text}; } - // If `text` is a Text component, we need to override any text colors within to ensure they all match - // @ts-expect-error - TS2339 - if (typeof text !== 'string' && Children.only(text)?.type.displayName === 'Text') { - const isDarkMode = colorSchemeName === 'darkMode'; - - const textColorOverrideStyles = isDarkMode - ? styles.textColorOverrideLight - : styles.textColorOverrideDark; - - return ( - - {cloneElement(text, { size: size || undefined })} - - ); + // If `text` is a Text component, we need to override any text size within to ensure they all match + if ( + text && + typeof text !== 'string' && + // @ts-expect-error - TS2339 + Children.only(text)?.type.displayName === 'Text' + ) { + return cloneElement(text, { size: size || undefined }); } throw new Error( diff --git a/packages/gestalt/src/__snapshots__/List.test.tsx.snap b/packages/gestalt/src/__snapshots__/List.test.tsx.snap index b6a4e61502..6cc66444f1 100644 --- a/packages/gestalt/src/__snapshots__/List.test.tsx.snap +++ b/packages/gestalt/src/__snapshots__/List.test.tsx.snap @@ -204,15 +204,11 @@ exports[`List renders an list item with custom text 1`] = ` } } > - -
- List item text -
-
+ List item text + @@ -227,15 +223,11 @@ exports[`List renders an list with a custom label 1`] = ` className="box marginBottom400 xsDisplayBlock" id=":rm:" > - -
- label test -
-
+ label test +