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

onopen callback for Drawer component #36728

Closed
2 tasks done
kcsujeet opened this issue Mar 31, 2023 · 4 comments
Closed
2 tasks done

onopen callback for Drawer component #36728

kcsujeet opened this issue Mar 31, 2023 · 4 comments
Assignees
Labels
component: drawer This is the name of the generic UI component, not the React module!

Comments

@kcsujeet
Copy link

kcsujeet commented Mar 31, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Summary 💡

Currently, there's no onOpen callback in drawer component and because of that I'm having to set a timeout to wait for the drawer to completely open and do something.

Examples 🌈

Here is the code sandbox. Link

Motivation 🔦

I want to do things when the drawer is completely opened. For example: open autocomplete programmatically.

@kcsujeet kcsujeet added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 31, 2023
@Depender-Sethi
Copy link

Actually, the Drawer component does have a callback that you can use to trigger an action when the opening transition is complete. It's called 'onTransitionEnd', and it's exactly what you're looking for. Instead of using a timeout to wait for the drawer to open completely, you can simply attach your desired action to the 'onTransitionEnd' callback, and it will be executed automatically when the opening transition is finished.

image

@kcsujeet
Copy link
Author

kcsujeet commented Apr 2, 2023

Actually, the Drawer component does have a callback that you can use to trigger an action when the opening transition is complete. It's called 'onTransitionEnd', and it's exactly what you're looking for. Instead of using a timeout to wait for the drawer to open completely, you can simply attach your desired action to the 'onTransitionEnd' callback, and it will be executed automatically when the opening transition is finished.

image

That's exactly what I was looking for. Why isn't this documented anywhere? .. I couldn't find this prop mentioned in either the Drawer docs or the Modal docs. Not even in the Transition component docs.

@Depender-Sethi
Copy link

Great to hear that 'onTransitionEnd' worked for you! The reason it wasn't mentioned in the MUI library documentation is because it's not actually a function of the library itself. Instead, 'onTransitionEnd' is an event that's triggered on certain HTML elements when a CSS transition is completed. You can find more information on this event in the MDN web docs (https://developer.mozilla.org/en-US/docs/Web/API/Element/transitionend_event). So while 'onTransitionEnd' isn't explicitly documented by MUI, it's a widely-used event in web development that can be applied to a variety of HTML elements.

@zannager zannager added the component: drawer This is the name of the generic UI component, not the React module! label Apr 3, 2023
@kcsujeet
Copy link
Author

kcsujeet commented Apr 3, 2023

@Depender-Sethi ... that makes complete sense. Thank you very much for your help. I appreciate it a lot. 🙌

@sai6855 sai6855 closed this as completed Apr 6, 2023
@sai6855 sai6855 removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: drawer This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

5 participants