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(text): variant loss with child component #4173

Merged

Conversation

hbriese
Copy link
Contributor

@hbriese hbriese commented Nov 9, 2023

Motivation

When a component is used as a child to Text i.e. <Text><MyComponent /></Text> the variant specified in the text is ignored.
i.e.

function Custom() {
  return <>{'<Custom /> nested in headlineMedium'}</>;
}

function Example() {
  return (
    <Text>
      <Custom />
    </Text>
  );
}

This is due to logic inside of the Text component trying to deal with nested Text components. This logic however applies to all components and breaks rendering components within Text.

Related issue

#4172

Test plan

  1. Text.test.tsx contains tests for regressions - nested text with variant should override parent's variant
  2. Added test to Text.test.tsx - nested non-text component should not override parent's variant

Before

image

After

image

@callstack-bot
Copy link

Hey @hbriese, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

hbriese added a commit to zallo-labs/zallo that referenced this pull request Nov 9, 2023
@lukewalczak lukewalczak self-assigned this Nov 14, 2023
@lukewalczak lukewalczak merged commit 333da92 into callstack:main Nov 23, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants