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

feat: add skeleton to drawer component #81

Closed
wants to merge 8 commits into from

Conversation

EnriqueePerez
Copy link

@EnriqueePerez EnriqueePerez commented Nov 6, 2024

What problem is this solving?

When the drawer contains too many components the INP performance time is too high. With this change, a skeleton (empty div) is shown while all the childrens are being mounted.

How to test it?

Workspace

Screenshots or example usage:

Screenshot 2024-11-06 at 11 22 12

Describe alternatives you've considered, if any.

Related to / Depends on

How does this PR make you feel? 🔗

![](put .gif link here - can be found under "advanced" on giphy)

@EnriqueePerez EnriqueePerez self-assigned this Nov 6, 2024
@EnriqueePerez EnriqueePerez requested a review from a team as a code owner November 6, 2024 08:45
@EnriqueePerez EnriqueePerez requested review from vsseixaso, RodrigoTadeuF and leo-prange-vtex and removed request for a team November 6, 2024 08:45
Copy link
Contributor

vtex-io-ci-cd bot commented Nov 6, 2024

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@vtex-io-docs-bot
Copy link

Beep boop 🤖

I noticed you didn't make any changes at the docs/ folder

  • There's nothing new to document 🤔
  • I'll do it later 😞

In order to keep track, I'll create an issue if you decide now is not a good time

  • I just updated 🎉🎉

@@ -159,6 +160,14 @@ function Drawer(props: Props) {
}
}, [onVisibilityChanged, isMenuOpen])

useEffect(() => {
if (isMenuOpen && !shouldRenderChildrenNow) {
setTimeout(() => {
Copy link
Contributor

@iago1501 iago1501 Nov 6, 2024

Choose a reason for hiding this comment

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

Why is this setTimeout necessary? if the main concern is about conflict, you could check with the prevState from useState set

Copy link
Author

Choose a reason for hiding this comment

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

Thanks to the setTimeout, the drawer will be rendered instanly, reducing the INP and the children are going to be mounted once the drawer is first mounted. I tried with promise but seems that the best approach is using this.

manifest.json Outdated Show resolved Hide resolved
react/Drawer.tsx Show resolved Hide resolved
@iago1501 iago1501 added the enhancement New feature or request label Nov 6, 2024
@iago1501 iago1501 closed this Nov 13, 2024
@iago1501 iago1501 reopened this Nov 13, 2024
@iago1501
Copy link
Contributor

This PR closes this one

@iago1501 iago1501 closed this Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants