File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,8 @@ def __call__(self) -> object:
157157
158158 async def run (self ) -> object :
159159 x = await self ._fn ()
160+ if x is None :
161+ return None
160162 widget = _as_widget (x )
161163 return {"model_id" : widget .model_id } # type: ignore
162164
Original file line number Diff line number Diff line change @@ -40,19 +40,27 @@ class IPyWidgetOutput extends Shiny.OutputBinding {
4040 this . renderError ( el , err ) ;
4141 }
4242 renderValue ( el : HTMLElement , data ) : void {
43- // TODO: allow for null value
43+
44+ // Allow for a None/null value to hide the widget (css inspired by htmlwidgets)
45+ if ( ! data ) {
46+ el . style . visibility = "hidden" ;
47+ return ;
48+ } else {
49+ el . style . visibility = "inherit" ;
50+ }
51+
4452 const model = manager . get_model ( data . model_id ) ;
4553 if ( ! model ) {
4654 throw new Error ( `No model found for id ${ data . model_id } ` ) ;
4755 }
56+
4857 model . then ( ( m ) => {
4958 const view = manager . create_view ( m , { } ) ;
5059 view . then ( v => {
5160 manager . display_view ( v , { el : el } ) . then ( ( ) => {
5261 // TODO: This is not an ideal way to handle the case where another render
5362 // is requested before the last one is finished displaying the view, but
5463 // it's probably the least unobtrusive way to handle this for now
55- //
5664 while ( el . childNodes . length > 1 ) {
5765 el . removeChild ( el . childNodes [ 0 ] ) ;
5866 }
You can’t perform that action at this time.
0 commit comments