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

Block stays expenaded with isOpened=false #303

Open
ascrazy opened this issue Jul 13, 2021 · 4 comments
Open

Block stays expenaded with isOpened=false #303

ascrazy opened this issue Jul 13, 2021 · 4 comments

Comments

@ascrazy
Copy link

ascrazy commented Jul 13, 2021

There appears to be a bug for the case when isOpened value changes to true and then immediatelly changes back to false (because of useEffect). Please see Demo2Inner in this Codepen - https://codepen.io/ascrazy/pen/MWmJWYR?editors=0010

Screen Shot 2021-07-13 at 15 24 56

@ascrazy ascrazy changed the title Block stays expenaded with isOpened=true Block stays expenaded with isOpened=false Jul 13, 2021
@ascrazy
Copy link
Author

ascrazy commented Jul 13, 2021

If I postpone syncyng up value and initialValue just for 50ms (so isOpened becomes true then switches back to false in ~50ms) - problem is gone.

    React.useEffect(() => {
      setTimeout(() => setValue(initialValue), 50);
    }, [initialValue]);

@bot19
Copy link

bot19 commented Nov 12, 2021

Also had the same issue. Can't believe something as obvious as this is a persisting bug. Fixed it by debouncing the state that is tied to Collapse opening & closing (https://thewebdev.info/2021/03/14/how-to-use-the-react-useeffect-hook-with-debounce/).

@nkbt
Copy link
Owner

nkbt commented Nov 12, 2021

Hey @bot19, if that is so obvious and this is a solution you believe is worth having - feel free to fork library, publish with your own namespace and use it. I am not getting paid for anything done here and I have spent a lot of my personal free time working on these libs and maintaining them as much as I could.
Good luck with your open-source journey 👌🏻

@tobia
Copy link

tobia commented Jan 23, 2023

The reason for this and other bugs is that the container's height is fixed into px every time React calls getSnapshotBeforeUpdate(), which happens a bunch of times during the normal application lifecycle.

This is fixed in kir4ik's pull request: #310

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

No branches or pull requests

4 participants