summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIsmo Haataja <ismo.haataja@digia.com>2014-10-08 15:28:01 +0300
committerIsmo Haataja <ismo.haataja@digia.com>2014-10-15 09:25:29 +0200
commit0a931b7fc43769a8b7cc6ef58e0cfa531e0903af (patch)
tree7cb7f1e39ef5ab417a42eeb87f8b9ca0a0e21c39
parentd124a6d287ef836b3290d92baa2f1e14b18a36bd (diff)
Fix for scrolling the active row visible in diff page
When using keyboard navigation keys in the diff page, the active row was not automatically scrolled into view in Chrome and IE. Firefox did not have the same problem, though. The 'scrollIntoView' function from 'com.google.gwt.client.Element' class just doesn't work correctly in those two browsers. Problem fixed by implementing an own version for scrolling the window to correct position. Task-number: QTQAINFRA-903 Change-Id: I170fa0e4d2f45fcab95e2af08ed9530b71c1ee15 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>
-rw-r--r--gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/NavigationTable.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/NavigationTable.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/NavigationTable.java
index 7e1add3914..7c41a43225 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/NavigationTable.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/NavigationTable.java
@@ -20,6 +20,7 @@ import com.google.gwt.dom.client.Document;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.ScrollPanel;
@@ -267,7 +268,18 @@ public abstract class NavigationTable<RowItem> extends FancyFlexTable<RowItem> {
}
});
} else {
- tr.scrollIntoView();
+ // tr.scrollIntoView(); works just for Firefox, not for Chrome and IE
+ // so replacing it with following which works for all three browsers
+ final int sTop = Window.getScrollTop();
+ final int sEnd = sTop + Window.getClientHeight();
+ final int eTop = tr.getAbsoluteTop();
+ final int eEnd = eTop + tr.getClientHeight();
+ // Element below view area
+ if (eEnd > sEnd) {
+ Window.scrollTo(Window.getScrollLeft(), eEnd - Window.getClientHeight());
+ } else if (eTop < sTop) { // Element above view area
+ Window.scrollTo(Window.getScrollLeft(), eTop);
+ }
}
}