Auto-resize panels to match content

RESOLVED INCOMPLETE

Status

Add-on SDK
General
P3
enhancement
RESOLVED INCOMPLETE
6 years ago
3 months ago

People

(Reporter: Connor Dunn, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

6 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1

Steps to reproduce:

Created a panel with content larger than the panel size.


Actual results:

Scrollbars.


Expected results:

Panel resized to match content size if the screen size allows it (see Chrome popups).

Maybe this could be enabled using a property when creating the panel?

Updated

6 years ago
Severity: normal → enhancement
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3
(Reporter)

Comment 1

6 years ago
I had a quick go at implementing this, I ran into difficulty working out where the panel was in relation to the screen, the normal window.screenX etc properties seemed to refer to the parent window rather than the popup.

Anyway in case its useful this is my code (currently resizes between a minimum and maximum size rather than the screen size).

(before "this._emit('show');" in panel.js around line 326)

      var self = this;
      doc.documentElement.addEventListener("DOMSubtreeModified", function(){
        self.resize(Math.min(Math.max(doc.documentElement.scrollWidth, 320), 500), Math.min(Math.max(doc.documentElement.scrollHeight, 240), 500));
      }, false);
Blocks: 821476

Comment 2

3 years ago
I've been trying to solve this since forever. I've always tried using a callback from the content script to the main code, passing it measurements to resize to. I tried to get the measurements from a dozen different combinations of anything I could find through google: document, documentElement, window, scrollWidth/Height, innerWidth/Height, boundingRectangle, etc. Nothing has ever worked reliably, it always ends up malformed. Opening the same html file in a tab shows the document the way it should be, so shouldn't it be possible to get the measurements of the document's natural layout and adjusting the panel to it?

Comment 3

3 years ago
For clarity: by it being unreliable, I meant that the results even differ between add-ons. One of my add-ons succesfully uses document.documentElement.scrollHeight/Width + 16, but the exact same code doesn't work at all in another add-on's panel.
https://bugzilla.mozilla.org/show_bug.cgi?id=1399562
Status: NEW → RESOLVED
Last Resolved: 3 months ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.