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

  1. https://www.primefaces.org/showcase/ui/misc/blockUI.xhtml?jfwid=06f1d
  2. open developer tools
  3. open the components.js file
  4. put the breakpoint to the 2837 row ('top': ((blocker.height() - content.outerHeight()) / 2) + 'px',)
  5. change the page in the Custom content table
  6. check the outerHeight()

or

  1. https://www.primefaces.org/showcase/ui/misc/blockUI.xhtml?jfwid=06f1d
  2. open developer tools, console
  3. execute $('#j_idt343\\:j_idt365').outerHeight();
  4. 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

Most upvoted comments

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