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

[core] Exclude undefined className from render fn props #1041

Merged
merged 3 commits into from
Dec 12, 2024

Conversation

mj12albert
Copy link
Member

@mj12albert mj12albert commented Dec 11, 2024

Fixes #993

When className is unspecified on the component, className inside the render function should not be overwritten by the renderFn's props.className:

<Toggle
  aria-label="Favorite"
  render={(props, state) => {
    if (state.pressed) {
      return (
        <button type="button" className={styles.Button} {...props}>
          <HeartFilledIcon />
        </button>
      );
    }

    return (
      <button type="button" className={styles.Button} {...props}>
        <HeartOutlineIcon />
      </button>
    );
  }}
/>

@mj12albert mj12albert added the core Infrastructure work going on behind the scenes label Dec 11, 2024
@mj12albert mj12albert changed the title Don't include undefined className in render fn props [core] Exclude undefined className from render fn props Dec 11, 2024
@mui-bot
Copy link

mui-bot commented Dec 11, 2024

Netlify deploy preview

https://deploy-preview-1041--base-ui.netlify.app/

Generated by 🚫 dangerJS against daa126f

@mj12albert mj12albert marked this pull request as ready for review December 11, 2024 09:47
@mj12albert mj12albert force-pushed the fix/render-fn-classname branch from 5241107 to fcc3d7f Compare December 11, 2024 09:48
Copy link
Contributor

@atomiks atomiks left a comment

Choose a reason for hiding this comment

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

Test would be nice

@mj12albert
Copy link
Member Author

Test would be nice

Added ~

@mj12albert mj12albert added the bug 🐛 Something doesn't work label Dec 12, 2024
@mj12albert mj12albert merged commit a89b832 into mui:master Dec 12, 2024
24 checks passed
@mj12albert mj12albert deleted the fix/render-fn-classname branch December 12, 2024 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[core] Render function props override className
3 participants