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

[popups] action prop #1236

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

[popups] action prop #1236

wants to merge 17 commits into from

Conversation

atomiks
Copy link
Contributor

@atomiks atomiks commented Dec 27, 2024

Closes #1160

JavaScript animations page. I focused on Motion fairly exclusively. The action prop holds imperative methods, currently just unmount. action.current.unmount() is for when animating opacity doesn't work in other libraries for the most part, as opacity: 0.9999 is really the simplest solution.

Motion experiments

Remove keepMounted on portal child parts

Remove unused imports

Remove keepMounted prop in tests
@atomiks atomiks added the core Infrastructure work going on behind the scenes label Dec 27, 2024
@mui-bot
Copy link

mui-bot commented Dec 27, 2024

Netlify deploy preview

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

Generated by 🚫 dangerJS against 49bf54c


const onFinished = useEventCallback(onFinishedParam);
const runOnceAnimationsFinish = useAnimationsFinished(animatedElementRef);
const openRef = useLatestRef(open);

useEnhancedEffect(() => {
React.useEffect(() => {
Copy link
Contributor Author

@atomiks atomiks Dec 27, 2024

Choose a reason for hiding this comment

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

Change to regular useEffect as the timing lets Motion know the exit animation styles have been applied inside a single requestAnimationFrame when checking for element.getAnimations() when keepMounted=true

});

React.useImperativeHandle(params.unmountRef, () => ({ unmount: handleUnmount }), [handleUnmount]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

An API with a bunch of imperative methods could be useful in general, not just for this, so it could be named something more generic to future-proof it. This concept may be similar to using hooks, or component stores as in Ariakit. One difference is you can't "read" values in render, it's just for accessing internal methods/state inside event handlers & effects (since it's a ref).

Copy link
Member

Choose a reason for hiding this comment

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

👍
A couple of Material UI components use this pattern and call the prop action (like https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ButtonBase/ButtonBase.d.ts#L13)

@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged and removed PR: out-of-date The pull request has merge conflicts and can't be merged labels Jan 2, 2025
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 7, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 7, 2025
@atomiks atomiks changed the title [POC] unmountRef prop [POC] action prop Jan 7, 2025
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 8, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 10, 2025
Copy link

netlify bot commented Jan 10, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 3c836fb
🔍 Latest deploy log https://app.netlify.com/sites/base-ui/deploys/678dff37449146000849086b
😎 Deploy Preview https://deploy-preview-1236--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@atomiks atomiks changed the title [POC] action prop [popups] action prop Jan 10, 2025
@atomiks atomiks marked this pull request as ready for review January 20, 2025 07:46
@atomiks atomiks requested a review from colmtuite as a code owner January 20, 2025 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JavaScript exit animations aren't properly supported
3 participants