Reputation: 405
I added a Tree in my GWT WebApp. Now when you click on an element the whole site is scrolling down. This often means I loose focus on my clicked object, so I have to move the mouse and click again on the item.
This is very annoying when you always have to click two times on one item.
Maybe there is a posiibility to remove this "autofocus-option", or someone have other ideas?
Upvotes: 3
Views: 1024
Reputation: 106
also it still possible to scroll to selected item, for example, when creating it from codebehind:
tree.addItem(treeItem);
treeItem.getElement().scrollIntoView();
though dynamically enabling autoscroll (setScrollOnSelectEnabled) before adding and disabling after may not work as expected
upd: the problem appears when treeitem is widget with autoscroll enabled. clicking item twice scrolls the tree top. pure text is still fine.
upd2: in some IEs setScrollOnSelectEnabled(false) have no effect, focus is still jumping up on widget item click. the reason seems execution flow finally reaches Element.focus() which causing incorrect behaviour (due to incorrect element?). it is starting from onSelection(moveFocus=true). with moveFocus=false it is fine. to disable this it is required to make own version of Tree with moveFocus disabled and call Element.focus() for correct element.
but! setScrollOnSelectEnabled(true) is fine, no jumping top on item second click! so workaround is enable this setting depending on browser detected.
Upvotes: 1
Reputation: 797
GWT 2.5.1 has a new option to fix that scrolling into view behavior. After creating a new Tree object call
tree.setScrollOnSelectEnabled(false);
to disable scrolling on selection.
Keep in mind that your tree will always be set to (0,0) scroll position after that. Which means that if the tree will happen to have scroll bars it might be a problem (it will then scroll to the top instead of keeping focus on selected item).
Upvotes: 2