Custom View tearDown not being called when component is "rendered out"

  • 1
  • Problem
  • Updated 2 years ago
When a custom view is visible (e.g. Table custom view), if the component (e.g. table) is "rendered out", the tearDown function is not being called. 

This leads to the inability to "cleanup" (e.g. unregister/remove/destroy) resources that the view has created/registered/etc.  Unfortunately, it is not possible to override the list or editor of a table in this case because the view doesn't "own" the editor/list and overriding these methods would impact those resources.  In short, there is no way to reliably "cleanup" a custom view when conditionally rendered "out".

Steps to reproduce
1) Create page using XML below
2) Preview page
3) Change to "Basic" view
4) Change to "List" View

Expected Behavior = Actual Behavior
tearDown is called (see console message)

5) Change to "Basic" view
6) Toggle the "HideTable" field above the table to 

Expected Behavior
tearDown is called when table is rendered "out"

Actual Behavior
tearDown is NOT called when table is rendered "out"

Sample Page
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true" tabtooverride="Product2">   <models>
      <model id="Product2" limit="100" query="true" createrowifnonefound="false" sobject="Product2" adapter="" type="">
         <fields>
            <field id="Name"/>
            <field id="CreatedDate"/>
            <field id="Id"/>
            <field id="Description"/>
            <field id="Family"/>
            <field id="ProductCode"/>
         </fields>
         <conditions/>
         <actions/>
      </model>
      <model id="Tracker" limit="1" query="false" createrowifnonefound="true" adapter="" type="" doclone="" sobject="Account">
         <fields>
            <field id="HideTable" uionly="true" displaytype="BOOLEAN" label="HideTable"/>
         </fields>
         <conditions/>
         <actions/>
      </model>
   </models>
   <components>
      <pagetitle model="Product2" uniqueid="sk-jswKP-68">
         <maintitle>
            <template>{{Model.labelPlural}}</template>
         </maintitle>
         <subtitle>
            <template>Home</template>
         </subtitle>
         <actions>
            <action type="savecancel"/>
         </actions>
      </pagetitle>
      <basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="Tracker" buttonposition="" uniqueid="sk-uhxOb-780" mode="edit">
         <columns>
            <column width="100%">
               <sections>
                  <section title="Section A" collapsible="no" showheader="false">
                     <fields>
                        <field id="HideTable" valuehalign="" type=""/>
                     </fields>
                  </section>
               </sections>
            </column>
         </columns>
      </basicfieldeditor>
      <skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Product2" mode="edit" uniqueid="sk-jswKP-69" emptysearchbehavior="query" buttonposition="">
         <fields>
            <field id="Name" allowordering="true"/>
            <field id="CreatedDate" allowordering="true"/>
         </fields>
         <rowactions>
            <action type="edit"/>
            <action type="delete"/>
         </rowactions>
         <massactions usefirstitemasdefault="true"/>
         <views>
            <view type="standard"/>
            <view type="custom" label="Basic" viewsnippet="basicView" icon="sk-icon-config"/>
         </views>
         <renderconditions logictype="and">
            <rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Tracker" sourcetype="fieldvalue" nosourcerowbehavior="skipandnorender" sourceproperty="hasChanged" value="true" operator="!=" field="HideTable"/>
         </renderconditions>
         <searchfields/>
      </skootable>
   </components>
   <resources>
      <labels/>
      <css/>
      <javascript>
         <jsitem location="inline" name="newInlineJS" cachelocation="false" url="">(function($, $S){
    
    $S.snippet.registerSnippet('basicView', function() {
        function setUp( list )
        {
            //console.log( 'setUp was called');
        }
        
        function beforeRender( list )
        {
            //console.log( 'beforeRender was called');            
        }
        
        function render( item )
        {
            //console.log( 'render was called');
            item.element.text( item.row.Name );
        }
        
        function renderComplete( list )
        {
            //console.log( 'renderComplete was called');
        }
        
        function tearDown( list )
        {
            console.log( 'tearDown was called - ' + Math.random());
        }
        
        return {
            render: render,
            setUp: setUp,
            beforeRender: beforeRender,
            renderComplete: renderComplete,
            tearDown: tearDown
        };
    });
})(skuid.$, skuid);</jsitem>
      </javascript>
   </resources>
   <styles>
      <styleitem type="background" bgtype="none"/>
   </styles>
</skuidpage>
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb

Posted 2 years ago

  • 1

Be the first to post a reply!