Browse Source

Fix for #5385

svn changeset:14429/svn branch:6.4
tags/6.7.0.beta1
John Alhroos 14 years ago
parent
commit
ba10d13395
1 changed files with 37 additions and 1 deletions
  1. 37
    1
      src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java

+ 37
- 1
src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java View File

@@ -4864,7 +4864,12 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
// Set new focused row
focusedRow = row;

row.getElement().scrollIntoView();
/*
* We can't use row.getElement.scrollIntoView() here. It will scroll
* the row right if the table has horizontal scrollbars. Using
* homegrown method instead. #5385
*/
ensureRowIsVisible(row);

return true;
}
@@ -4872,6 +4877,37 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
return false;
}

/**
* Ensures that the row is visible
*
* @param row
* The row to ensure is visible
*/
private void ensureRowIsVisible(VScrollTableRow row) {
boolean hasHorizontalScrollbars = scrollBody.getOffsetHeight() > scrollBodyPanel
.getOffsetHeight();
int rowTop = row.getElement().getOffsetTop();
int rowBottom = rowTop + row.getElement().getOffsetHeight();
int bodyTop = scrollBodyPanel.getScrollPosition();
int bodyBottom = bodyTop + getElement().getScrollHeight()
- tHead.getOffsetHeight();

// Take into account horizontal scrollbars
bodyBottom -= hasHorizontalScrollbars ? row.getOffsetHeight() : 0;

// Scrolling above body
if (rowTop < bodyTop) {
int diff = bodyTop - rowTop;
scrollBodyPanel.setScrollPosition(bodyTop - diff);
}

// Scrolling below body
if (rowBottom > bodyBottom) {
int diff = rowBottom - bodyBottom;
scrollBodyPanel.setScrollPosition(bodyTop + diff);
}
}

/**
* Handles the keyboard events handled by the table
*

Loading…
Cancel
Save