MVP scroll position is reset on place change

91 views
Skip to first unread message

Dzmitry Lazerka

unread,
Jan 3, 2012, 9:53:40 PM1/3/12
to google-we...@googlegroups.com
Hi geeks,

I've got an interesting problem:

I have a long vertical list of widgets. Each widget has assigned click handler, which eventually calls placeController.goTo(). The new place maps to the same activity class, which reuses the same instance of view with the vertical list of widgets.

The problem is that when I do 
  public void start(AcceptsOneWidget panel, EventBus eventBus) {
    panel.setWidget(view.asWidget());
  }
in the activity, it resets scroll position of my vertical list to the top, and users has to scroll it down again to find the item they just clicked.

I'm not sure how to easily fix that, because GWT doesn't explicitly resets the scroll position, it just reattaches the view widget to the same parent. Any ideas?

Thomas Broyer

unread,
Jan 4, 2012, 5:12:42 AM1/4/12
to google-we...@googlegroups.com
How about also reusing the same activity instance? that way, it won't be stopped/restarted, and so its view won't be detached/reattached, and the scroll position should be maintained.

Dzmitry Lazerka

unread,
Jan 5, 2012, 9:39:08 PM1/5/12
to google-we...@googlegroups.com
That works, thank you!

Now I'm going to review and refactor all activities scopes to singleton.
Reply all
Reply to author
Forward
0 new messages