Tomas Jelinek has uploaded a new change for review.

Change subject: userportal,webadmin: Unable to scroll down template list using 
IE9
......................................................................

userportal,webadmin: Unable to scroll down template list using IE9

Three issues:
1: when clicking the scrollbar next to the template selection, IE9 did not fire
 a click event properly (a known IE9 bug). Fixed by attaching the listeners to
 the parent element (the whole suggestion box).

2: when using up/down keys, the proper template has been selected, but the view
 was not scrolled into it. Fixed by scrolling into the view after pressing
 arrow keys and also when opening the suggestions.

3: tweaked the CSS a bit so the content of the suggestions are not shifted

Tested on IE9 and FF.

Change-Id: I93312c75f7605cb007ae395d900ef8ced35c6b14
Bug-Url: https://bugzilla.redhat.com/1100194
Signed-off-by: Tomas Jelinek <tjeli...@redhat.com>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/BaseListModelSuggestBox.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.java
2 files changed, 52 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/51/29851/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/BaseListModelSuggestBox.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/BaseListModelSuggestBox.java
index 93b1690..039f92f 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/BaseListModelSuggestBox.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/BaseListModelSuggestBox.java
@@ -11,6 +11,7 @@
 import com.google.gwt.event.logical.shared.ValueChangeEvent;
 import com.google.gwt.event.logical.shared.ValueChangeHandler;
 import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.HasConstrainedValue;
 import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
@@ -158,6 +159,10 @@
      */
     protected abstract T asEntity(String value);
 
+    protected void scrollSelectedItemIntoView() {
+
+    }
+
     @Override
     public T getValue() {
         return value;
@@ -183,13 +188,21 @@
         private Widget suggestionMenu;
 
         public ListModelSuggestionDisplay(int maxSuggestionPanelHeightInPx) {
-            // not be hidden under the panel
             getPopupPanel().getElement().getStyle().setZIndex(1);
 
-            Style suggestPopupContentStyle = 
getPopupPanel().getWidget().getElement().getParentElement().getStyle();
+            Element popupPanelElement = 
getPopupPanel().getWidget().getElement();
+            Style popupPanel = popupPanelElement.getStyle();
+            popupPanel.setDisplay(Style.Display.BLOCK);
+            popupPanel.setHeight(100, Unit.PCT);
+            popupPanel.setPropertyPx("maxHeight", 
maxSuggestionPanelHeightInPx); //$NON-NLS-1$
+            popupPanel.setOverflowY(Overflow.SCROLL);
+            popupPanel.setOverflowX(Overflow.HIDDEN);
+
+            Style suggestPopupContentStyle = 
popupPanelElement.getParentElement().getStyle();
             suggestPopupContentStyle.setHeight(100, Unit.PCT);
             suggestPopupContentStyle.setPropertyPx("maxHeight", 
maxSuggestionPanelHeightInPx); //$NON-NLS-1$
             suggestPopupContentStyle.setOverflowX(Overflow.HIDDEN);
+            suggestPopupContentStyle.setProperty("display", "table"); 
//$NON-NLS-1$ //$NON-NLS-2$
         }
 
         // just to make it public
@@ -215,5 +228,20 @@
             this.suggestionMenu = suggestionList;
             return super.decorateSuggestionList(suggestionList);
         }
+
+        @Override
+        protected void moveSelectionUp() {
+            super.moveSelectionUp();
+
+            scrollSelectedItemIntoView();
+        }
+
+        @Override
+        protected void moveSelectionDown() {
+            super.moveSelectionDown();
+
+            scrollSelectedItemIntoView();
+        }
+
     }
 }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.java
index 118f5b5..c669296 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.java
@@ -1,6 +1,7 @@
 package org.ovirt.engine.ui.common.widget.editor;
 
 import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.dom.client.Element;
 import com.google.gwt.event.dom.client.FocusHandler;
 import com.google.gwt.event.dom.client.MouseDownEvent;
 import com.google.gwt.event.dom.client.MouseDownHandler;
@@ -122,10 +123,10 @@
             }
         });
 
-        getSuggestionMenu().addDomHandler(new 
FocusHandlerEnablingMouseHandlers(handlers), MouseDownEvent.getType());
+        getSuggestionMenu().getParent().addDomHandler(new 
FocusHandlerEnablingMouseHandlers(handlers), MouseDownEvent.getType());
 
         // no need to do additional switchSuggestions() - it is processed by 
MenuBar itself
-        getSuggestionMenu().addDomHandler(new 
FocusHandlerEnablingMouseHandlers(handlers), MouseUpEvent.getType());
+        getSuggestionMenu().getParent().addDomHandler(new 
FocusHandlerEnablingMouseHandlers(handlers), MouseUpEvent.getType());
 
         asSuggestBox().addValueChangeHandler(new ValueChangeHandler<String>() {
             @Override
@@ -197,6 +198,7 @@
             if (acceptableValueReplacement != null && 
acceptableValueReplacement.equals(selectedReplacementString)) {
                 if (items.size() > selectedItemIndex) {
                     menuBar.selectItem(items.get(selectedItemIndex));
+                    scrollSelectedItemIntoView();
                 }
 
                 break;
@@ -204,11 +206,29 @@
         }
     }
 
+    protected void scrollSelectedItemIntoView() {
+        if (!(getSuggestionMenu() instanceof MenuBar)) {
+            // can not select if it is not a menu bar
+            return;
+        }
+
+        MenuBar menuBar = (MenuBar) getSuggestionMenu();
+        MenuItem item = getSelectedItem(menuBar);
+        if (item != null) {
+            Element toSelect = item.getElement().getParentElement();
+            toSelect.scrollIntoView();
+        }
+    }
+
     // extremely ugly - there is just no better way how to find the items as 
MenuItems
     private native List<MenuItem> getItems(MenuBar menuBar) /*-{
         return menub...@com.google.gwt.user.client.ui.MenuBar::getItems()();
     }-*/;
 
+    private native MenuItem getSelectedItem(MenuBar menuBar) /*-{
+        return 
menub...@com.google.gwt.user.client.ui.MenuBar::getSelectedItem()();
+    }-*/;
+
     private void adjustSelectedValue() {
         if (acceptableValues.size() == 0) {
             return;


-- 
To view, visit http://gerrit.ovirt.org/29851
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I93312c75f7605cb007ae395d900ef8ced35c6b14
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Tomas Jelinek <tjeli...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to