Skip to content

Commit

Permalink
feat: make Scroller implement Focusable (#5738)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunovianarezende authored and mvysny committed Nov 23, 2023
1 parent 35ca245 commit 1fcddb3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<ScrollerVariant> {
public class Scroller extends Component implements Focusable<Scroller>, HasSize,
HasStyle, HasThemeVariant<ScrollerVariant> {

private static final String SCROLL_DIRECTION_PROPERTY = "scrollDirection";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +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;

public class ScrollerTest {

Expand Down Expand Up @@ -84,4 +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() {
Input input = new Input();

scroller.setContent(new VerticalLayout(input));
Assert.assertTrue(input.isEnabled());

scroller.setEnabled(false);
Assert.assertFalse(input.isEnabled());
}
}

0 comments on commit 1fcddb3

Please sign in to comment.