Outsystems Tabs API
OutsystemsUI js file
Outsystems UI 2.16.0
inside function _setTabHeaderItemDisabledStatus(childHeaderId, isDisabled)
when disabling a tab via the OutsystemsUI client action for Tabs (DisableTabItem), line 9590 (shown below) sets display: none; directly on the html element for the div tag w/ data-block=Navigation.TabContentItem:OSUI.Helper.Dom.Styles.SetStyleAttribute(_tabContentItemElement, OSUI.GlobalEnum.InlineStyle.Display, OSUI.GlobalEnum.InlineStyleValue.Display.none);
This is fine. The problem is that, when enabling the tab via the OutsystemsUI client action (EnableTabItem), the "display" value for that same element is set to "block" in line 9598:
OSUI.Helper.Dom.Styles.SetStyleAttribute(_tabContentItemElement, OSUI.GlobalEnum.InlineStyle.Display, OSUI.GlobalEnum.InlineStyleValue.Display.block);
There are two problems with this (the second of which is why I tag this as a bug)
@Garrett Nygren ,
I can repeat the same, it is not even about inline vs block, there is a rule in the OutSystems css that normally makes it display:content, but after disabling and enabling, that is overridden by an inline style of block.
before :
after :
I'm thinking that this code is an oversight, if they are working with inline styles, it should just remove the display:none inline at the point of enabling.
Dorine
PS : a tip : The product owner of OutSystems UI, @Gonçalo Martins , is really good at following up on the forum if anything comes up relating to his products. But for him to see it, you have to link your post to the OutsystemsUI forge asset.
I have just done that for you, now.
Yes, the element override of display: block was what I was trying to illuminate w/ my original post.
I wasn't sure what the best way to link/tag things was for this situation; thank you very much for doing that for me.
Hi Garrett,
The other way to deal with this situation is to create a CSS class (.d-none {display: none !important; }) to toggle the display and then use that class on the tab header item with a required conditional flag (showTab). Further, you can change the flag (showTab = True/False) with client action and tab item could be toggled.
Simple CSS trick could do the job.
Hope this helps!
Hiding the disabled tab content using display: none isn't the misbehaving part of the existing client action. How the client action gets the tab to re-display is. Furthermore, a lot more happens inside the enable/disable tab actions than simply setting display: none on the content elements, so I didn't want to go down the path of re-making the default UI client actions.
What I wound up doing was just biting the bullet and making sure the rest of my CSS behaved the way I wanted it to whether the content items had display: inline or display: block.
Using conditional classes is indeed a good trick :) I try not to use !important if I can help it, even in those conditional classes.
I have created a sample app to show the implementation which is not breaking or misbehaving with the Outsystems design and approach.
You can do whatever you want to on the client action and there is no need to re-write the default actions as well.
I understand your concern with !important, so I have used OS provided "hidden" class and you can write style with more CSS specificity in case "hidden" is getting overridden by any other custom style.
Check the demo here - Tabs Demo
Hi @Garrett Nygren ,
please update your JS with below JS,
function _setTabHeaderItemDisabledStatus(childHeaderId, isDisabled) {
const _tabHeaderItemElement = document.getElementById(childHeaderId);
const _tabContentItemElement = document.querySelector(`[data-block="Navigation.TabContentItem"][data-tab-id="${childHeaderId}"]`);
if (_tabHeaderItemElement && _tabContentItemElement) {
if (isDisabled) {
// Store the original display style
_tabContentItemElement.setAttribute('data-original-display', _tabContentItemElement.style.display || 'inline');
// Add a class to hide the element
_tabContentItemElement.classList.add('tab-content-item-hidden');
} else {
// Remove the class to show the element
_tabContentItemElement.classList.remove('tab-content-item-hidden');
// Restore the original display style
const originalDisplay = _tabContentItemElement.getAttribute('data-original-display');
_tabContentItemElement.style.display = originalDisplay;
_tabContentItemElement.removeAttribute('data-original-display');
}
and use CSS as
.tab-content-item-hidden { display: none !important; }
with this JS will update when to hide and when not to.
Hope this helps,
Thanks,
Adarsh Patel
Hello @Garrett Nygren
This will be fixed on the next version under the task ROU-10913 for reference in the release notes.
Cheers,GM