GibbsConsulting / django-plotly-dash

Expose plotly dash apps as django tags
MIT License
538 stars 121 forks source link

Issue using All-in-One Component in DjangoDash app #452

Open anjunatl opened 1 year ago

anjunatl commented 1 year ago

I'm porting a Dash app to DPD for work & ran into an issue with a custom All-in-One Component on a % plotly_direct dash app. it's a dash-bootstrap-components modal that displays when the user interacts with a table row. The modal display toggle worked OK without any extra intervention, but the Save/Cancel buttons inside the modal do not work anymore. Clicking on them does nothing & no errors are thrown to the console.

I'm curious if there's any additional setup I need to do, or if this might relate to @callback vs app=DjangoDash(...) & @app.callback, or if I'm missing something else that might be causing this issue.

dash==2.9.2
dash-bootstrap-components==1.3.0
django-plotly-dash==2.1.4
Django==3.2.18
django-bootstrap4==23.1

Thanks for your time & for maintaining this library 😄 I'm hoping this might be a known issue -- if example code is needed let me know & I can make a generic example repo to reproduce the issue.

delsim commented 1 year ago

Reproductions are always good, and sometimes essential. However first a couple of quick questions might throw some light on the issue:

Frankly, the closest we have to a known issue is the plotly_direct tag itself; it breaks the encapsulation that a lot of plotly dash relies on and as a result there are plenty of problems that can arise due to various conflicts and errors etc. I would strongly encourage you to use a different tag to include the dpd app if at all possible.

anjunatl commented 1 year ago

@delsim Thanks for the debugging help! I'll get an example together & link it when it's ready.

The modal AIO in question has a @callback defined to handle clicks on the Save/Cancel buttons, is it possible this callback's not being registered since it doesn't have an app = DjangoDash(..) ..... @app.callback() definition ?

delsim commented 1 year ago

@anjunatl callbacks for sure do need to be registered with the DjangoDash app; this app in turn instantiates an underlying Dash app with wrapped versions of each callback.

It looks like the structure of AIO is not compatible with dpd at the moment - essentially as it uses a new @callback decorator.