summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Murtojärvi <mika@vaadin.com>2015-06-17 07:56:55 +0000
committerMika Murtojarvi <mika@vaadin.com>2015-06-17 11:34:20 +0300
commitb34500197a833080ae7ab25898207fa96ee016e6 (patch)
treef3165f54898066418caa5de9b8bd07110e15517a
parent3aebda062b2d179f21d546294a7127caf92517f8 (diff)
downloadvaadin-framework-7.5.0.rc2.tar.gz
vaadin-framework-7.5.0.rc2.zip
Revert "Prevent field from updating when removing text change listener.7.5.0.rc2
(#16270)" This reverts commit 4af793d06a0f4a6577aad13403ca7982c6fce224. Test ConverterThatEnforcesAFormatTest.checkElaborating is broken by this change. Change-Id: I08dba8e47386dfb001caafae562304858ad02348
-rw-r--r--client/src/com/vaadin/client/ui/textfield/TextFieldConnector.java5
-rw-r--r--server/src/com/vaadin/ui/AbstractTextField.java33
-rw-r--r--uitest/src/com/vaadin/tests/components/textfield/RemoveTextChangeListener.java32
-rw-r--r--uitest/src/com/vaadin/tests/components/textfield/RemoveTextChangeListenerTest.java24
4 files changed, 21 insertions, 73 deletions
diff --git a/client/src/com/vaadin/client/ui/textfield/TextFieldConnector.java b/client/src/com/vaadin/client/ui/textfield/TextFieldConnector.java
index fad094b87f..0d85e98ee3 100644
--- a/client/src/com/vaadin/client/ui/textfield/TextFieldConnector.java
+++ b/client/src/com/vaadin/client/ui/textfield/TextFieldConnector.java
@@ -89,9 +89,10 @@ public class TextFieldConnector extends AbstractFieldConnector implements
* side value). <input> is updated only when it looses focus, so we
* force updating if not focused. Lost focus issue appeared in (#15144)
*/
- if (Util.getFocusedElement() != getWidget().getElement()
+ if (!(Util.getFocusedElement() == getWidget().getElement())
|| !uidl.getBooleanAttribute(TextFieldConstants.ATTR_NO_VALUE_CHANGE_BETWEEN_PAINTS)
- || getWidget().valueBeforeEdit == null) {
+ || getWidget().valueBeforeEdit == null
+ || !text.equals(getWidget().valueBeforeEdit)) {
getWidget().updateFieldContent(text);
}
diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java
index 14c135228c..93025ac0fd 100644
--- a/server/src/com/vaadin/ui/AbstractTextField.java
+++ b/server/src/com/vaadin/ui/AbstractTextField.java
@@ -126,22 +126,25 @@ public abstract class AbstractTextField extends AbstractField<String> implements
selectionPosition = -1;
}
- target.addAttribute(TextFieldConstants.ATTR_TEXTCHANGE_EVENTMODE,
- getTextChangeEventMode().toString());
- target.addAttribute(TextFieldConstants.ATTR_TEXTCHANGE_TIMEOUT,
- getTextChangeTimeout());
- if (lastKnownTextContent != null) {
- /*
- * The field has be repainted for some reason (e.g. caption, size,
- * stylename), but the value has not been changed since the last
- * text change event. Let the client side know about the value the
- * server side knows. Client side may then ignore the actual value,
- * depending on its state.
- */
- target.addAttribute(
- TextFieldConstants.ATTR_NO_VALUE_CHANGE_BETWEEN_PAINTS,
- true);
+ if (hasListeners(TextChangeEvent.class)) {
+ target.addAttribute(TextFieldConstants.ATTR_TEXTCHANGE_EVENTMODE,
+ getTextChangeEventMode().toString());
+ target.addAttribute(TextFieldConstants.ATTR_TEXTCHANGE_TIMEOUT,
+ getTextChangeTimeout());
+ if (lastKnownTextContent != null) {
+ /*
+ * The field has be repainted for some reason (e.g. caption,
+ * size, stylename), but the value has not been changed since
+ * the last text change event. Let the client side know about
+ * the value the server side knows. Client side may then ignore
+ * the actual value, depending on its state.
+ */
+ target.addAttribute(
+ TextFieldConstants.ATTR_NO_VALUE_CHANGE_BETWEEN_PAINTS,
+ true);
+ }
}
+
}
@Override
diff --git a/uitest/src/com/vaadin/tests/components/textfield/RemoveTextChangeListener.java b/uitest/src/com/vaadin/tests/components/textfield/RemoveTextChangeListener.java
deleted file mode 100644
index 339160e6ff..0000000000
--- a/uitest/src/com/vaadin/tests/components/textfield/RemoveTextChangeListener.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.vaadin.tests.components.textfield;
-
-import com.vaadin.event.FieldEvents;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.ui.TextField;
-
-public class RemoveTextChangeListener extends AbstractTestUI {
- @Override
- protected void setup(VaadinRequest request) {
- final TextField textfield = new TextField();
-
- textfield.addTextChangeListener(new FieldEvents.TextChangeListener() {
- @Override
- public void textChange(FieldEvents.TextChangeEvent event) {
- textfield.removeTextChangeListener(this);
- }
- });
-
- addComponent(textfield);
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 16270;
- }
-
- @Override
- protected String getTestDescription() {
- return "Removing text change listener on text change event should not reset the input.";
- }
-}
diff --git a/uitest/src/com/vaadin/tests/components/textfield/RemoveTextChangeListenerTest.java b/uitest/src/com/vaadin/tests/components/textfield/RemoveTextChangeListenerTest.java
deleted file mode 100644
index 0b876864bc..0000000000
--- a/uitest/src/com/vaadin/tests/components/textfield/RemoveTextChangeListenerTest.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.vaadin.tests.components.textfield;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-import org.junit.Test;
-
-import com.vaadin.testbench.elements.TextFieldElement;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-public class RemoveTextChangeListenerTest extends MultiBrowserTest {
-
- @Test
- public void serverValueIsUpdated() {
- openTestURL();
-
- TextFieldElement textfield = $(TextFieldElement.class).first();
-
- textfield.sendKeys("f");
-
- assertThat(textfield.getValue(), is("f"));
- }
-
-} \ No newline at end of file