aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorGuillermo Alvarez <guillermo@vaadin.com>2014-08-05 18:45:14 +0300
committerVaadin Code Review <review@vaadin.com>2014-08-07 10:50:33 +0000
commit409a41ce44f577170f4c84211515dbb5815f5642 (patch)
tree5549f4ce7eccf637d3967d82bb84eaef2fe2d279 /client
parent80d72d34d9bc2f6686b607177ff6c89ff845728e (diff)
downloadvaadin-framework-409a41ce44f577170f4c84211515dbb5815f5642.tar.gz
vaadin-framework-409a41ce44f577170f4c84211515dbb5815f5642.zip
Correctly display an item which is too long for the textfield. (#13477)
As setSelectionRange is not working correctly in IE the current approach sets the direction before setting the text and resets it to the original immediately after that. Change-Id: I33f40f9ae436122092d995fa17c35a9cbe38aedb
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ui/VFilterSelect.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java
index 46f90c07fa..6ba0785acc 100644
--- a/client/src/com/vaadin/client/ui/VFilterSelect.java
+++ b/client/src/com/vaadin/client/ui/VFilterSelect.java
@@ -46,6 +46,7 @@ import com.google.gwt.event.dom.client.LoadEvent;
import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
+import com.google.gwt.i18n.client.HasDirection.Direction;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
@@ -452,9 +453,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
setSelectedItemIcon(suggestion.getIconUri());
// Set the text.
- tb.setText(text);
- tb.setSelectionRange(lastFilter.length(), text.length()
- - lastFilter.length());
+ setText(text);
menu.updateKeyboardSelectedItem();
}
@@ -916,11 +915,11 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
&& !currentSuggestion.key.equals("")) {
// An item (not null) selected
String text = currentSuggestion.getReplacementString();
- tb.setText(text);
+ setText(text);
selectedOptionKey = currentSuggestion.key;
} else {
// Null selected
- tb.setText("");
+ setText("");
selectedOptionKey = null;
}
}
@@ -1060,7 +1059,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
if (textInputEnabled) {
super.setSelectionRange(pos, length);
} else {
- super.setSelectionRange(getValue().length(), 0);
+ super.setSelectionRange(0, getValue().length());
}
}
}
@@ -1452,7 +1451,19 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
if (enableDebug) {
debug("VFS: setTextboxText(" + text + ")");
}
+ setText(text);
+ }
+
+ private void setText(final String text) {
+ /**
+ * To leave caret in the beginning of the line.
+ * SetSelectionRange wouldn't work on IE
+ * (see #13477)
+ */
+ Direction previousDirection = tb.getDirection();
+ tb.setDirection(Direction.RTL);
tb.setText(text);
+ tb.setDirection(previousDirection);
}
/**