From 0baf24f0b6e5c0a58d9d80311f78e4ab729e9fe4 Mon Sep 17 00:00:00 2001 From: Bruno Rezende Date: Thu, 16 Nov 2023 16:04:01 -0300 Subject: [PATCH 1/2] feat: make Scroller implement Focusable --- .../vaadin-ordered-layout-flow/pom.xml | 6 ++++++ .../flow/component/orderedlayout/Scroller.java | 5 +++-- .../component/orderedlayout/tests/ScrollerTest.java | 12 ++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/pom.xml b/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/pom.xml index c6b554dee23..9494ecfe157 100644 --- a/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/pom.xml +++ b/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/pom.xml @@ -26,6 +26,12 @@ flow-html-components test + + com.vaadin + vaadin-text-field-flow + ${project.version} + test + com.vaadin flow-test-generic diff --git a/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/src/main/java/com/vaadin/flow/component/orderedlayout/Scroller.java b/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/src/main/java/com/vaadin/flow/component/orderedlayout/Scroller.java index 17437454f57..83f3fa7ce34 100644 --- a/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/src/main/java/com/vaadin/flow/component/orderedlayout/Scroller.java +++ b/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/src/main/java/com/vaadin/flow/component/orderedlayout/Scroller.java @@ -16,6 +16,7 @@ package com.vaadin.flow.component.orderedlayout; import com.vaadin.flow.component.Component; +import com.vaadin.flow.component.Focusable; import com.vaadin.flow.component.HasSize; import com.vaadin.flow.component.HasStyle; import com.vaadin.flow.component.Tag; @@ -39,8 +40,8 @@ @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @NpmPackage(value = "@vaadin/scroller", version = "24.3.0-alpha11") @JsModule("@vaadin/scroller/src/vaadin-scroller.js") -public class Scroller extends Component - implements HasSize, HasStyle, HasThemeVariant { +public class Scroller extends Component implements Focusable, HasSize, + HasStyle, HasThemeVariant { private static final String SCROLL_DIRECTION_PROPERTY = "scrollDirection"; diff --git a/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/src/test/java/com/vaadin/flow/component/orderedlayout/tests/ScrollerTest.java b/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/src/test/java/com/vaadin/flow/component/orderedlayout/tests/ScrollerTest.java index ae4305de48e..938a74bcce0 100644 --- a/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/src/test/java/com/vaadin/flow/component/orderedlayout/tests/ScrollerTest.java +++ b/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/src/test/java/com/vaadin/flow/component/orderedlayout/tests/ScrollerTest.java @@ -22,6 +22,8 @@ import com.vaadin.flow.component.html.Div; import com.vaadin.flow.component.orderedlayout.Scroller; import com.vaadin.flow.component.orderedlayout.Scroller.ScrollDirection; +import com.vaadin.flow.component.orderedlayout.VerticalLayout; +import com.vaadin.flow.component.textfield.TextField; public class ScrollerTest { @@ -84,4 +86,14 @@ public void setNullScrollDirection_NullPointerExceptionIsThrown() { scroller.setScrollDirection(null); } + @Test + public void setEnabled_disableChildren() { + TextField textField = new TextField(); + + scroller.setContent(new VerticalLayout(textField)); + Assert.assertTrue(textField.isEnabled()); + + scroller.setEnabled(false); + Assert.assertFalse(textField.isEnabled()); + } } From 561e5f4b65e1817958719ac41df642fffbbfa83e Mon Sep 17 00:00:00 2001 From: Bruno Rezende Date: Wed, 22 Nov 2023 14:20:20 -0300 Subject: [PATCH 2/2] Remove test dependency with TextField and add test for Focusable implementation --- .../vaadin-ordered-layout-flow/pom.xml | 6 ------ .../orderedlayout/tests/ScrollerTest.java | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/pom.xml b/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/pom.xml index 9494ecfe157..c6b554dee23 100644 --- a/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/pom.xml +++ b/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/pom.xml @@ -26,12 +26,6 @@ flow-html-components test - - com.vaadin - vaadin-text-field-flow - ${project.version} - test - com.vaadin flow-test-generic diff --git a/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/src/test/java/com/vaadin/flow/component/orderedlayout/tests/ScrollerTest.java b/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/src/test/java/com/vaadin/flow/component/orderedlayout/tests/ScrollerTest.java index 938a74bcce0..fb78e510e55 100644 --- a/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/src/test/java/com/vaadin/flow/component/orderedlayout/tests/ScrollerTest.java +++ b/vaadin-ordered-layout-flow-parent/vaadin-ordered-layout-flow/src/test/java/com/vaadin/flow/component/orderedlayout/tests/ScrollerTest.java @@ -19,11 +19,12 @@ import org.junit.Before; import org.junit.Test; +import com.vaadin.flow.component.Focusable; import com.vaadin.flow.component.html.Div; +import com.vaadin.flow.component.html.Input; import com.vaadin.flow.component.orderedlayout.Scroller; import com.vaadin.flow.component.orderedlayout.Scroller.ScrollDirection; import com.vaadin.flow.component.orderedlayout.VerticalLayout; -import com.vaadin.flow.component.textfield.TextField; public class ScrollerTest { @@ -86,14 +87,20 @@ public void setNullScrollDirection_NullPointerExceptionIsThrown() { scroller.setScrollDirection(null); } + @Test + public void implementsFocusable() { + Assert.assertTrue("Scroller should be focusable", + Focusable.class.isAssignableFrom(scroller.getClass())); + } + @Test public void setEnabled_disableChildren() { - TextField textField = new TextField(); + Input input = new Input(); - scroller.setContent(new VerticalLayout(textField)); - Assert.assertTrue(textField.isEnabled()); + scroller.setContent(new VerticalLayout(input)); + Assert.assertTrue(input.isEnabled()); scroller.setEnabled(false); - Assert.assertFalse(textField.isEnabled()); + Assert.assertFalse(input.isEnabled()); } }