diff options
author | Tapio Aali <tapio@vaadin.com> | 2013-07-16 16:15:01 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2013-07-16 16:42:06 +0300 |
commit | 3229847265dc30cced90e6718bd477cf4e9fbdf4 (patch) | |
tree | 964a5726c62ce67f3fb67dfaec1318ef988c5285 /client | |
parent | a93426164d5766fd7e0a687c1a7c98ce53aaa1c7 (diff) | |
download | vaadin-framework-3229847265dc30cced90e6718bd477cf4e9fbdf4.tar.gz vaadin-framework-3229847265dc30cced90e6718bd477cf4e9fbdf4.zip |
Fix lost focus in Table when refreshing row cache (#12231)
svn changeset:25991/svn branch:6.8
svn changeset:26075/svn branch:6.8
svn changeset:26091/svn branch:6.8
Change-Id: Ia4a6ab4cc6ff98795a6d1f9b1701a345dc3f4dc4
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/VScrollTable.java | 4 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/table/TableConnector.java | 18 |
2 files changed, 19 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index e2e82a1959..2d177f29b5 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -194,7 +194,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, private SelectMode selectMode = SelectMode.NONE; - private final HashSet<String> selectedRowKeys = new HashSet<String>(); + public final HashSet<String> selectedRowKeys = new HashSet<String>(); /* * When scrolling and selecting at the same time, the selections are not in @@ -568,7 +568,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, this.rowKey = rowKey; this.left = left; this.top = top; - this.closeRegistration = menu.addCloseHandler(this); + closeRegistration = menu.addCloseHandler(this); } @Override diff --git a/client/src/com/vaadin/client/ui/table/TableConnector.java b/client/src/com/vaadin/client/ui/table/TableConnector.java index 36587ffe4d..47229dc9c7 100644 --- a/client/src/com/vaadin/client/ui/table/TableConnector.java +++ b/client/src/com/vaadin/client/ui/table/TableConnector.java @@ -266,7 +266,23 @@ public class TableConnector extends AbstractHasComponentsConnector implements if (!getWidget().focusedRow.isAttached() && !getWidget().rowRequestHandler.isRunning()) { // focused row has been orphaned, can't focus - getWidget().focusRowFromBody(); + if (getWidget().selectedRowKeys.contains(getWidget().focusedRow + .getKey())) { + // if row cache was refreshed, focused row should be + // in selection and exists with same index + getWidget().setRowFocus( + getWidget().getRenderedRowByKey( + getWidget().focusedRow.getKey())); + } else if (getWidget().selectedRowKeys.size() > 0) { + // try to focus any row in selection + getWidget().setRowFocus( + getWidget().getRenderedRowByKey( + getWidget().selectedRowKeys.iterator() + .next())); + } else { + // try to focus any row + getWidget().focusRowFromBody(); + } } } |