primefaces: BlockUI: The content outerHeight is not computed
Describe the bug
Jquery cannot compute the height of the element that the parent element has display:none
.
<div style="position:absolute; display:none; height:100px; width:100px; top:20px; left:40px;" class="ui-blockui">
<div style="position:absolute; display:none" class="ui-blockui-content">
<span>In progress</span>
</div>
</div>
The ui-blockui-content
has the wrong position.
/**
* Align the overlay so it covers its target component.
* @private
*/
alignOverlay: function() {
...
//center position of content
for (var i = 0; i < this.target.length; i++) {
...
blocker.css(sizeAndPosition);
content.css({
'left': ((blocker.width() - content.outerWidth()) / 2) + 'px',
'top': ((blocker.height() - content.outerHeight()) / 2) + 'px', // THE OUTERHEIGHT IS NOT COMPUTED
'z-index': PrimeFaces.nextZindex()
});
}
The ui-blockui-content
element is inner because there is the implementation of multiple targets, maybe it’s not correct. In the render function, the content is appended to the ui-blockui
element and it’s wrong.
The blockUI implementation in PF 11 works well, the height of the ui-blockui-content
is computed correctly.
Reproducer
- https://www.primefaces.org/showcase/ui/misc/blockUI.xhtml?jfwid=06f1d
- open developer tools
- open the components.js file
- put the breakpoint to the 2837 row (
'top': ((blocker.height() - content.outerHeight()) / 2) + 'px',
) - change the page in the Custom content table
- check the outerHeight()
or
- https://www.primefaces.org/showcase/ui/misc/blockUI.xhtml?jfwid=06f1d
- open developer tools, console
- execute
$('#j_idt343\\:j_idt365').outerHeight();
- it returns 0
Expected behavior
The content of the blocker has the correct position, it’s well-centered.
PrimeFaces edition
Community
PrimeFaces version
12.0.0
Theme
No response
JSF implementation
Mojarra
JSF version
2.3
Java version
11
Browser(s)
Chromium 106.0.5249.119
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (19 by maintainers)
Commits related to this issue
- Fix #9496: BlockUI calculate content dimensions if hidden — committed to melloware/primefaces by melloware 2 years ago
- Fix #9496: BlockUI calculate content dimensions if hidden (#9520) — committed to primefaces/primefaces by melloware 2 years ago
- Fix #9496: BlockUI check height for display:none — committed to melloware/primefaces by melloware a year ago
- Fix #9496: BlockUI check height for display:none — committed to melloware/primefaces by melloware a year ago
- Fix #9496: BlockUI check height for display:none (#9961) — committed to primefaces/primefaces by melloware a year ago
- Fix #9496: check for negative heights — committed to primefaces/primefaces by melloware a year ago
I almost did that originally but thought it would never be negative. 😄 Let me fix
it works fine. Thanks a lot.
Awesome I updated the MonkeyPatch above with all these changes in case others want to use it. Waiting for build to finish and I will merge these changes