Page 1 of 1

Dialog initially without scrollbar

Posted: Wed Feb 03, 2021 7:18 pm
by Patrik
Hi,

I have a dialog that contains a lot of content so it should have a scrollbar. But initially there is no scrollbar. When I resize the dialog (explicitly or by resizing the browser window) the scrollbar appears. Also when I perform the action again (the dialog is a member).

Hier is the code of my minimized sample:

Code: Select all

DialogTestAction = function (editor) {
	sync.actions.AbstractAction.call(this, '');
	this.editor = editor;
	this.dialog = workspace.createDialog();
};

DialogTestAction.prototype = Object.create(sync.actions.AbstractAction.prototype);
DialogTestAction.prototype.constructor = DialogTestAction;

DialogTestAction.prototype.getDisplayName = function () {
	return 'Dialog-Test';
};

DialogTestAction.prototype.actionPerformed = function (callback) {
	this.dialog.setTitle('Ergebnis');
	this.dialog.getElement().innerHTML = '<p style="min-width: 200px">';
	for (i = 0; i < 30; i++) {
		this.dialog.getElement().innerHTML += 'Test Test Test<br/>';
  	}
	this.dialog.getElement().innerHTML += '</p>';
	this.dialog.show();
	this.dialog.focus();
};
My workaround is to make the dialog resizable so the user can reszie it and let the scrollbar appear. But I'd prefer the scroll bar to be thare right at the beginning. Any suggestions how to achieve that?

Thanks and regards,
Patrik

Re: Dialog initially without scrollbar

Posted: Thu Feb 04, 2021 3:13 pm
by mihai_coanda
Hello Patrik,

Thank you for reporting this issue. I have added an internal issue on it.
To work around this issue you could set the dialog's preferred size using the following code snippet:

Code: Select all

this.dialog.setPreferredSize(300, 500);
to any values you desire.

Regards,
Michael

Re: Dialog initially without scrollbar

Posted: Thu Feb 04, 2021 8:35 pm
by Patrik
Hi Michael,

thanks for the workaround - although it is not realy working for me since the content is generated dynamically and I can hardly guess any reasonable preferred size. But makingit resizable to the user can "activate" the scrollbar manually will work for now.

Regards,
Patrik

Re: Dialog initially without scrollbar

Posted: Fri Feb 05, 2021 9:41 am
by mihai_coanda
Hi Patrik

As you cannot determine a suitable dialog height you could set a very large height that would force the dialog size recalculation to fit the screen:

Code: Select all

  this.dialog.setPreferredSize(null, 50000);
This would also enable the dynamic width of the dialog to better fit the content.

Regards,
Michael.

Re: Dialog initially without scrollbar

Posted: Fri Feb 05, 2021 10:17 am
by Patrik
Hi Michael,

thanks, but the content might also be only a single line - which looks very strange on a full-screen-dialog... ;)

But I implemented a simple algorithm to guess if the content is large, and set the preferred hight to null or 10000 depending on that. This works fine!

Regards,
Patrik

Re: Dialog initially without scrollbar

Posted: Fri Feb 05, 2021 10:46 am
by mihai_coanda
Hi Patrick,

Glad that you found a solution that best suits your needs.

I will update this thread once the issue is fixed.

Regards,
Michael