Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

BottomComponentScrollsUp.java 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package com.vaadin.tests.components.window;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import com.vaadin.server.VaadinRequest;
  5. import com.vaadin.tests.components.AbstractReindeerTestUI;
  6. import com.vaadin.ui.Alignment;
  7. import com.vaadin.ui.Button;
  8. import com.vaadin.ui.Panel;
  9. import com.vaadin.ui.VerticalLayout;
  10. import com.vaadin.ui.Window;
  11. /**
  12. * Reproducing bug #12943 where an action on a Button or ComboBox placed at the
  13. * bottom of a window in a scroll panel, will scroll up the parent panel.
  14. *
  15. * This was due to the fact that with the state confirmation notification from
  16. * the server, the window.setVisible would be call again, and the hack that
  17. * solved the scrollbars in a window (#11994) would cause the our bug.
  18. *
  19. * @author Vaadin Ltd
  20. */
  21. @SuppressWarnings("serial")
  22. public class BottomComponentScrollsUp extends AbstractReindeerTestUI {
  23. @Override
  24. protected void setup(VaadinRequest request) {
  25. Button b = new Button("Open window");
  26. addComponent(b);
  27. b.addClickListener(event -> openWindow());
  28. openWindow();
  29. }
  30. private void openWindow() {
  31. Window w = new Window();
  32. w.setWidth("300px");
  33. w.setHeight("300px");
  34. w.center();
  35. Panel p = createPanel();
  36. p.setSizeFull();
  37. w.setContent(p);
  38. addWindow(w);
  39. }
  40. private Panel createPanel() {
  41. Panel p = new Panel();
  42. VerticalLayout content = new VerticalLayout();
  43. content.setMargin(false);
  44. content.setSpacing(false);
  45. p.setContent(content);
  46. content.setHeight("500px");
  47. List<String> items = new ArrayList<>();
  48. items.add("1");
  49. items.add("2");
  50. items.add("3");
  51. Button button = new Button("Press me");
  52. content.addComponent(button);
  53. content.setComponentAlignment(button, Alignment.BOTTOM_CENTER);
  54. return p;
  55. }
  56. @Override
  57. protected String getTestDescription() {
  58. return "Interacting with a component at the bottom of scrollable panel within a subwindow scrolls up";
  59. }
  60. @Override
  61. protected Integer getTicketNumber() {
  62. return 12943;
  63. }
  64. }