displayed promise should probably trigger on after-show if widget is initially invisible
See original GitHub issueRight now, the Javascript side of a widget has a displayed
promise that triggers on after-attach
. However, some libraries actually need to know when they are visible on the page, not just attached (for example, initially sizing things in bqplot needs to measure its size after the browser has laid out things). This comes up if your widget is in a non-active tab in the stock Tab widget, for example, where the after-attach
event triggers because you are added to the DOM, but you are not visible until later, when the user clicks on the tab (and then your widget gets a Lumino after-show
event).
Should we:
A. change the semantics of the displayed promise to only trigger on after-attach
if the widget is visible, and trigger on the first after-show
otherwise?
B. Leave displayed
to be tied to after-attach
and push the logic down to the widget author. If you really need to wait until you have visibility, set up their own promise that waits for an after-show
event after the displayed event? Or if you are already setting up Lumino event processing in your custom widget, perhaps you should tie into the Lumino after-attach
event instead of the ipywidgets displayed
promise?
I think A probably makes sense? Are there widgets that will want to do some processing after attachment even if they are invisible?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (9 by maintainers)
Top GitHub Comments
On the other hand, we could just encourage people to process the Lumino
after-attach
andafter-show
Lumino events, and ignore thedisplayed
promise.This was mainly closed by #3300 together with the discussion in this issue. Note also the planned changes in #2605.