setvisible resets the scroll position of a page

We’re developing Vaadin portlets (v6.8.10) and deploying them to Liferay. We’re noticing that whenever the visibility of a component is modified, setVisible(), the page refreshes and the vertical scroll position on the page is lost.

Is there a way to avoid losing/reseting the vertical scroll position when showing/hiding UI components? If not, what are others doing to avoid this issue and make the page more user friendly?

Thanks in advance.

Hi Eric,
although it is probably not connected with your issue, can you tell on what version of Liferay you’re experiencing this?

We’re using Vaadin 6.8.10

I’m actually having the exact same problem. Same version of Vaadin and Liferay 6.1.20 EE GA2.

Appreciate any insight you could offer into this.

I tried the to replicate the problem with Vaadin 7.1.9 and Liferay 6.1.1-ce-ga2, but it worked just fine, so maybe it’s version-specific either with Vaadin 6 or the newer Liferay.

Eric, Maciej asked about your Liferay version, not Vaadin.

Anyhow, it sounds a lot like a bug, although I wonder what could cause it. If hiding some element really causes Liferay to refresh the page, it should also occur when removing components. That would cause a lot of trouble with most Vaadin portlets.

I suppose you could file a ticket. It would, however, be interesting to know what could cause the problem, so if you can find something out, it would help greatly in fixing the problem.

I tested with the following Vaadin 7 code:

public class MyportletUI extends UI {

	@Override
	protected void init(VaadinRequest request) {
		final VerticalLayout layout = new VerticalLayout();
		layout.setMargin(true);
		setContent(layout);
		
		final Label hidingLabel = new Label("I'm now visible");
		layout.addComponent(hidingLabel);

		CheckBox box = new CheckBox("Visible");
		box.addValueChangeListener(new ValueChangeListener() {
			
			@Override
			public void valueChange(ValueChangeEvent event) {
				hidingLabel.setVisible((Boolean) event.getProperty().getValue());
			}
		});
		box.setImmediate(true);
		layout.addComponent(box);
	}

}

I’m using Liferay 6.1.20 EE GA2.

I’ve investigated this problem more, and it seems like it’s related to the com.vaadin.ui.Table (https://vaadin.com/forum#!/thread/4558721)

I have a similar problem that might be related. I have a table half of which is below the bottom of the page. When I use setCurrentPageFirstItemId on it to make the selected row visible in the table, the entire page jumps down so that the newly selected row is visible. If I just select a row without using setCurrentPageFirstItemId then the page doesn’t move.

Interestingly this happens on Firefox and IE but not on opera.

I believe the table and page scrolling behavior you mentioned is unrelated to the original topic of this thread. I’m not quite certain if I understand your description of the issue correctly, though.

The interaction between focus and scrolling is quite complicated in browsers and varies a lot from browser to browser. Some related issues with Table have been addressed in
#6197
.

If there are differences between browsers and this causes problems, you can
create a ticket
. In that case, please include information about the exact use case, desired and actual behavior in the various cases and the browser versions together with how they behave.

Well I thought it was related because both have to do with changing focus which causes the page to scroll.

In my case I have a large UI with a table that is off screen (below the bottom of the page) and when I call setCurrentPageFirstItemId on it the browser page scrolls down to make the selected row visible.
Is that the way it’s supposed to work ? What I would like is for only the table to scroll (offscreen) and the page to remain where it is.
I was wrong that it doesn’t happen on opera. I does but it’s a bit inconsistent.