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

Remove transition state from render props #3312

Merged
merged 4 commits into from
Jun 21, 2024

Conversation

RobinMalfait
Copy link
Member

This PR makes sure that the transition data, such as closed, enter, leave and transition is only mapped as data attributes e.g.: data-closed.

This PR removes the information from the render prop.

<Menu>
  <MenuItems>
    {({ ... /* Won't include `closed`, `enter`, `leave`, or `transition` */ }) => (
      <>
        <MenuItem as="a" href="#">
          Alice
        </MenuItem>
        <MenuItem as="a" href="#">
          Bob
        </MenuItem>
        <MenuItem as="a" href="#">
          Charlie
        </MenuItem>
      </>
    )}
  </MenuItems>
</Menu>

Instead of in the `slot` because this would also expose this information
as render props but we just want to set it as props without exposing it
as render props.
Copy link

vercel bot commented Jun 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 21, 2024 1:52pm
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 21, 2024 1:52pm

@@ -463,6 +463,7 @@ function TransitionChildFn<TTag extends ElementType = typeof DEFAULT_TRANSITION_
// Map data attributes to `entered` class (backwards compatibility)
!slot.transition && show && entered
)?.trim() || undefined, // If `className` is an empty string, we can omit it
...transitionDataAttributes(slot),
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably rename slot to transitionData just so we don't accidentally add this back

@RobinMalfait RobinMalfait changed the title Only expose transition data attributes as props, not in the render prop Remove transition state from render props Jun 21, 2024
@RobinMalfait RobinMalfait merged commit f144666 into main Jun 21, 2024
8 checks passed
@RobinMalfait RobinMalfait deleted the feat/remove-transition-data-from-render-prop branch June 21, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants