Skip to content

displayed promise should probably trigger on after-show if widget is initially invisible #2762

@jasongrout

Description

@jasongrout

Right 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?

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions