]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix slider inside table is not accessible.(#13681)
authorAnna Miroshnik <anna.miroshnik@arcadia.spb.ru>
Tue, 9 Sep 2014 10:17:06 +0000 (14:17 +0400)
committerAnna Miroshnik <anna.miroshnik@arcadia.spb.ru>
Tue, 9 Sep 2014 12:49:10 +0000 (12:49 +0000)
some fixes after review.
HiddenSliderHandle extends AbstractTestUI instead of UI now.

Change-Id: I83578014ae83219941da745e8373614854c937d7

client/src/com/vaadin/client/ui/VSlider.java
uitest/src/com/vaadin/tests/components/slider/HiddenSliderHandle.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/slider/HiddenSliderHandleTest.java [new file with mode: 0644]

index a6ff8fabb4bdf18306ff2643b3899fac74894eeb..3b82fd1525fed0086ed96b48e1485c57437d821e 100644 (file)
@@ -191,37 +191,44 @@ public class VSlider extends SimpleFocusablePanel implements Field,
         // clear unnecessary opposite style attribute
         base.getStyle().clearProperty(oppositeStyleAttribute);
 
-        if (!getElement().hasParentElement()) {
-            return;
-        }
-
-        final Element p = getElement().getParentElement();
-        if (p.getPropertyInt(domProperty) > 50) {
-            if (isVertical()) {
-                setHeight();
+        /*
+         * To resolve defect #13681 we should not return from method buildBase()
+         * if slider has no parentElement, because such operations as
+         * buildHandle() and setValues(), which are needed for Slider, are
+         * called at the end of method buildBase(). And these methods will not
+         * be called if there is no parentElement. So, instead of returning from
+         * method buildBase() if there is no parentElement "if condition" is
+         * applied to call code for parentElement only in case it exists.
+         */
+        if (getElement().hasParentElement()) {
+            final Element p = getElement().getParentElement();
+            if (p.getPropertyInt(domProperty) > MIN_SIZE) {
+                if (isVertical()) {
+                    setHeight();
+                } else {
+                    base.getStyle().clearProperty(styleAttribute);
+                }
             } else {
-                base.getStyle().clearProperty(styleAttribute);
-            }
-        } else {
-            // Set minimum size and adjust after all components have
-            // (supposedly) been drawn completely.
-            base.getStyle().setPropertyPx(styleAttribute, MIN_SIZE);
-            Scheduler.get().scheduleDeferred(new Command() {
-
-                @Override
-                public void execute() {
-                    final Element p = getElement().getParentElement();
-                    if (p.getPropertyInt(domProperty) > (MIN_SIZE + 5)) {
-                        if (isVertical()) {
-                            setHeight();
-                        } else {
-                            base.getStyle().clearProperty(styleAttribute);
+                // Set minimum size and adjust after all components have
+                // (supposedly) been drawn completely.
+                base.getStyle().setPropertyPx(styleAttribute, MIN_SIZE);
+                Scheduler.get().scheduleDeferred(new Command() {
+
+                    @Override
+                    public void execute() {
+                        final Element p = getElement().getParentElement();
+                        if (p.getPropertyInt(domProperty) > (MIN_SIZE + 5)) {
+                            if (isVertical()) {
+                                setHeight();
+                            } else {
+                                base.getStyle().clearProperty(styleAttribute);
+                            }
+                            // Ensure correct position
+                            setValue(value, false);
                         }
-                        // Ensure correct position
-                        setValue(value, false);
                     }
-                }
-            });
+                });
+            }
         }
 
         if (!isVertical()) {
diff --git a/uitest/src/com/vaadin/tests/components/slider/HiddenSliderHandle.java b/uitest/src/com/vaadin/tests/components/slider/HiddenSliderHandle.java
new file mode 100644 (file)
index 0000000..105c20f
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.slider;
+
+import com.vaadin.data.Item;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Slider;
+import com.vaadin.ui.Table;
+
+public class HiddenSliderHandle extends AbstractTestUI {
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        Table t = new Table();
+        Slider s = new Slider();
+        t.setWidth("200px");
+        s.setWidth("100px");
+        t.addContainerProperty("s", Slider.class, null);
+        Item i = t.addItem("123");
+        i.getItemProperty("s").setValue(s);
+        getLayout().addComponent(t);
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "Slider's handler should be accessible (visible) if slider is put inside table";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 13681;
+    }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/slider/HiddenSliderHandleTest.java b/uitest/src/com/vaadin/tests/components/slider/HiddenSliderHandleTest.java
new file mode 100644 (file)
index 0000000..3717f7f
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.slider;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class HiddenSliderHandleTest extends MultiBrowserTest {
+
+    @Test
+    public void handleIsAccessible() throws IOException {
+        openTestURL();
+
+        assertThat(getSliderHandle().isDisplayed(), is(true));
+    }
+
+    private WebElement getSliderHandle() {
+        return driver.findElement(By.className("v-slider-handle"));
+    }
+}