Page 1 of 1

destroy + create panel several times shows only the first panel

Posted: Wed Feb 08, 2023 3:49 pm
by pincherhgz

situation (we created that as an internal test case):

we create a panel via:

async function generateShowView(objectNode,form,initiatingElement){
      var tabPanelItems = getTabPanelItems(objectNode,form);
      // in case of read only we do not set the save button
      var tbarItems = {};
      if (!(eciDreadOnly === true)){
        tbarItems.save = {icon    : 'b-fa-save',tooltip : Ext.application.hummingbirdApi.getLocalized('Save content'),onClick : 'up.onSaveButtonClick'};
        var readOnlyText = '';
      } else {
        var readOnlyText = ' (' + Ext.application.hummingbirdApi.getLocalized('read only') + eciDalreadyInUse + ')';
      }
      let itemDetail = new bryntum.grid.Panel({
        title:objectNode.classIdentifier + ': ' + Ext.application.hummingbirdApi.getLocalized(objectNode.objectName) + readOnlyText,
        floating:true,
        maxHeight:'90%',
        width:'50%',
        modal:true,
        draggable:true,
        tbar : {
            items : tbarItems
        },
        tools    : {
            destroy : {
                cls : 'b-fa b-fa-times',
                handler : 'up.onPanelCloseClick',
                tooltip : Ext.application.hummingbirdApi.getLocalized('Close this Panel')
            }
        },
        onPanelCloseClick(e, panel) {
            unRegisterProtectApplication();
            panel.destroy();
        },
        items      : [
          {
              type:'tabpanel',
              floating:true,
              items: tabPanelItems
          }
        ],
        onSaveButtonClick({ source : button }) {
          saveObjectNode(objectNode);
          itemDetail.destroy();
        }
      });
      itemDetail.showBy({target:initiatingElement,anchor:true});
    }

we call that function more than one time, every time with different text set, always the panel is destroyed on entering the function and recreated, but the content that is shown is that one of the first panel


Re: destroy + create panel several times shows only the first panel

Posted: Thu Feb 09, 2023 3:22 am
by alex.l

HI pincherhgz,

Is it ExtGantt or vanilla Gantt? Did you try it with our examples?
Did you inspect DOM, maybe it's aligned on same position because you call https://bryntum.com/products/gantt/docs/api/Core/widget/Widget#function-showBy , so it align every new panel on same position?


Re: destroy + create panel several times shows only the first panel

Posted: Thu Feb 09, 2023 6:19 am
by pincherhgz

hi, we are using vanilla gantt and yes, all the panels are positioned at the same place. When we set a breakpoint it correctly destroys and shows up with the new contents


Re: destroy + create panel several times shows only the first panel

Posted: Thu Feb 09, 2023 6:30 am
by alex.l

Re: destroy + create panel several times shows only the first panel

Posted: Thu Feb 09, 2023 6:43 am
by pincherhgz

but the question is if i always destroy the existing before creating the next one ?


Re: destroy + create panel several times shows only the first panel

Posted: Thu Feb 09, 2023 7:22 am
by alex.l

Ah, sorry, I missed that moment in your description.
Could you please provide runnable code to reproduce this problem? That might be some race condition thing that we need to debug at runtime, but I cannot run your code.


Re: destroy + create panel several times shows only the first panel

Posted: Thu Feb 09, 2023 8:00 am
by pincherhgz

it seams that the problem is caused by destroying and creating directly one after the other in the async function. We changed now to have the panel in a popup, no need for async, and that way the destroy/create works


Re: destroy + create panel several times shows only the first panel

Posted: Thu Feb 09, 2023 2:43 pm
by alex.l

Great to hear you managed that!