mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 23:28:14 +00:00
[Tabs] Fix "Eager Load Tabs" option (#4371)
* If eager load is checked, tabs are pre-fetched and kept alive. * If eager load is not checked, tabs are not pre-fetched, and are not kept alive
This commit is contained in:
@ -152,6 +152,10 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addTabToLoaded(tab) {
|
addTabToLoaded(tab) {
|
||||||
|
if (!this.internalDomainObject.keep_alive) {
|
||||||
|
this.loadedTabs = {};
|
||||||
|
}
|
||||||
|
|
||||||
this.loadedTabs[tab.keyString] = true;
|
this.loadedTabs[tab.keyString] = true;
|
||||||
},
|
},
|
||||||
setCurrentTabByIndex(index) {
|
setCurrentTabByIndex(index) {
|
||||||
|
@ -173,9 +173,34 @@ describe('the plugin', function () {
|
|||||||
return Vue.nextTick();
|
return Vue.nextTick();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
count = 0;
|
||||||
|
});
|
||||||
|
|
||||||
it ('renders a tab for each item', () => {
|
it ('renders a tab for each item', () => {
|
||||||
let tabEls = element.querySelectorAll('.js-tab');
|
let tabEls = element.querySelectorAll('.js-tab');
|
||||||
|
|
||||||
expect(tabEls.length).toEqual(2);
|
expect(tabEls.length).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('with domainObject.keep_alive set to', () => {
|
||||||
|
|
||||||
|
it ('true, will keep all views loaded, regardless of current tab view', () => {
|
||||||
|
let tabViewEls = element.querySelectorAll('.c-tabs-view__object');
|
||||||
|
|
||||||
|
expect(tabViewEls.length).toEqual(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it ('false, will only keep the current tab view loaded', async () => {
|
||||||
|
testViewObject.keep_alive = false;
|
||||||
|
|
||||||
|
await Vue.nextTick();
|
||||||
|
|
||||||
|
let tabViewEls = element.querySelectorAll('.c-tabs-view__object');
|
||||||
|
|
||||||
|
expect(tabViewEls.length).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user