I tweaked the answer provided by Marc. Toggling the open status would sometimes make the first panel open then close again. This variation simply adds the open class.
angular.module('umbraco.services').config([
'$httpProvider',
function ($httpProvider) {
$httpProvider.interceptors.push(function ($q, $location) {
return {
'response': function (response) {
if (response.config.url.includes('/umbraco/backoffice/UmbracoApi/Content/GetById')
|| response.config.url.includes('umbraco/backoffice/UmbracoApi/Content/GetEmpty')) {
if (response.status === 200) {
window.setTimeout(function () {
var tabs = document.getElementsByClassName("umb-group-panel__header");
for (var i = 0; i < tabs.length; i++) {
if (tabs[i].onclick == null) {
tabs[i].onclick = function () {
this.classList.toggle("open");
this.nextElementSibling.classList.toggle("open");
}
}
}
tabs[0].classList.add("open");
tabs[0].nextElementSibling.classList.add("open");
}, 500)
}
}
return response;
}
};
});
}
]);
I discovered that the component sometimes throws an angular exception in the console regarding classList not being available. This only happens when editing document types. So I added a couple checks to prevent it from firing in that scenario.
Inside the window.setTimeout, use this block instead:
var tabs = document.getElementsByClassName("umb-group-panel__header");
if (tabs) {
for (var i = 0; i < tabs.length; i++) {
if (tabs[i].onclick == null) {
tabs[i].onclick = function () {
this.classList.toggle("open");
this.nextElementSibling.classList.toggle("open");
}
}
}
if (tabs[0]) {
tabs[0].classList.add("open");
tabs[0].nextElementSibling.classList.add("open");
}
}
Default open tab?
Could you either default the topmost tab to being open, or allow for setting a default open tab"?
Hi Michael,
Yes it should be possible to default the top tab to open, I will take a look.
If you replace the controller with this code the first tab will be open by default:
]);
I tweaked the answer provided by Marc. Toggling the open status would sometimes make the first panel open then close again. This variation simply adds the open class.
I've uploaded a new version which now defaults the first tab to open.
Please can you mark this as answered / closed?
I discovered that the component sometimes throws an angular exception in the console regarding classList not being available. This only happens when editing document types. So I added a couple checks to prevent it from firing in that scenario.
Inside the window.setTimeout, use this block instead:
is working on a reply...