Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2254

ModalWindow size may exceed browser viewport making it impossible to close

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.3.6
    • 1.4.11, 1.5-M2.1
    • wicket-extensions
    • None

    Description

      If a modal window is created with a size that is larger than what is available in the browser viewport, the user will be unable to close the window. The close button is displayed over the top of the window, making it impossible to reach.

      The problem lies in the center() function inside modal.js and is easy enough to fix:

      + // BUGFIX: Adjust the width and height to maximum values
      + if (modalWidth > width - 10)

      { + this.window.style.width = (width - 10) + "px"; + modalWidth = this.window.offsetWidth; + }

      + if (modalHeight > height - 40)

      { + this.content.style.height = (height - 40) + "px"; + modalHeight = this.window.offsetHeight; + }

      var left = (width / 2) - (modalWidth / 2) + scLeft;
      var top = (height / 2) - (modalHeight / 2) + scTop;
      + // BUGFIX: Ensure positive position values
      + this.window.style.left = Math.max(left, 0) + "px";
      + this.window.style.top = Math.max(top, 0) + "px";

      Note that the above code also ensures that the window position is positive at all times.

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            percederberg Per Cederberg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: