Giter Site home page Giter Site logo

Comments (10)

FRosner avatar FRosner commented on June 5, 2024

I wonder if this is caused by fade or delay? I'm trying to find the code that updates the is_open erroneously... @tcbegley can you help me?

Is it here?

const hide = () => {
if (isOpenRef.current) {
hideTimeout.current = clearTimeout(hideTimeout.current);
setIsOpen(false);
if (setProps) {
setProps({is_open: false});
}
}
};
// Function to create the delay for hiding if currently open
const hideWithDelay = () => {
if (!isOpenRef.current && showTimeout.current) {
showTimeout.current = clearTimeout(showTimeout.current);
hide();
} else if (isOpenRef.current) {
clearTimeout(hideTimeout.current);
hideTimeout.current = setTimeout(hide, delay.hide);
}
};

If it's delay, setting delay={"show": 0, "hide": 0}, should be a reasonable workaround.

from dash-bootstrap-components.

tcbegley avatar tcbegley commented on June 5, 2024

Hi @FRosner,

Thanks for reporting this and for providing so much detail and a minimal reproduction.

The issue is indeed in hideWithDelay. When the "close" even happens, we call setProps({is_open: false}) with a delay. In this case in the intervening time the component is unmounted. That means when Dash tries to update the prop the component no longer exists.

I think the fix here will be to either:

  1. modify the timeout so that the call to setProps only happens if the component hasn't been unmounted
  2. cancel outstanding timeouts when the component unmounts

I think 2) is probably cleaner but looking over the code briefly might require a bit of refactoring. I'll see what I can do.

from dash-bootstrap-components.

FRosner avatar FRosner commented on June 5, 2024

I'll see what I can do.

Thank you so much!

from dash-bootstrap-components.

FRosner avatar FRosner commented on June 5, 2024

I think the fix here will be to either:

To me, 1 sounds preferrable, as it has limited side effects and makes it clearer when the function is passed to setTimeout that this is something to be aware of. Why do you think 2 is cleaner?

from dash-bootstrap-components.

tcbegley avatar tcbegley commented on June 5, 2024

Why do you think 2 is cleaner?

Well the timeouts only make sense in the context of the component, so if the component no longer exists it seems neater to stop them from running at all rather than to run and do little / nothing. But tbh both options are similar so I'll take whatever solution is simpler to implement.

I did have a go at getting this to work yesterday but it turned out to be fiddlier than expected. I might need to refresh some of my react knowledge and try again when I get a chance.

from dash-bootstrap-components.

FRosner avatar FRosner commented on June 5, 2024

Thanks! I am trying the workaround of setting hide delay to 0 in the meantime. I'd also take a stab at it but last time I used react is 5 years ago :D

from dash-bootstrap-components.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.