shopware / admin-extension-sdk

The Admin Extension SDK can be used by Shopware 6 apps and plugins. This library allows them to extend the administration with custom functionality.
https://developer.shopware.com/resources/admin-extension-sdk/
46 stars 13 forks source link

Feature request: Add an event emitter for click event on `sw-tabs` #56

Open crisalder2806 opened 2 years ago

crisalder2806 commented 2 years ago

sw-tabs is not emitting anything out currently, so we don't know which is the active item. Could you help to add it?

jleifeld commented 1 year ago

Thanks for the suggestion. Can you give an example use case where you need it? Then it is easier to create a good solution which also covers your case

horfic commented 1 year ago

HI, e.g. you add a specific app tab into sw-product-detail which is loading information from an external source or does some other things. Now you only want to start loading the content of the tab if its active to reduce load on the server and also make the ui faster.

another example. i try to load per app a custom entity table which lists all transaction information for an order and presents details, i currently do not now what order i'm actively looking at and need to use sessionstorage to save the entity.id per data subscribe on sw-order-detail-base__order. unfortunately this event is only triggered on a page refresh when im on the general tab, not if i refresh on my custom tab, requires to currently switch between tabs to get this information.

cheers, Horst

seggewiss commented 9 months ago

Please correct me if I'm wrong but this sounds like the SDK should be capable of this already.

Let me elaborate on what I expect to happen with tabs.

  1. You add a tab via:

    ui.tabs('sw-product-detail').addTabItem({
    label: 'Example tab',
    componentSectionId: 'example-product-detail-tab-content'
    })
  2. Module loads and the General Tab is displayed 2.1 Your app iframe is not displayed and therefore should not load any data

  3. The user clicks your tab you load your data

The second part you mentioned @horfic sounds like a different problem for me. The issue is not that you don't know which tab you are on but more that the relation between tab and parent module information is missing.

Please correct me on any of these points, if I misunderstood something 😊