You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BottomComponentScrollsUp.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.components.window;
  17. import java.util.ArrayList;
  18. import java.util.List;
  19. import com.vaadin.server.VaadinRequest;
  20. import com.vaadin.tests.components.AbstractTestUI;
  21. import com.vaadin.ui.Alignment;
  22. import com.vaadin.ui.Button;
  23. import com.vaadin.ui.Button.ClickEvent;
  24. import com.vaadin.ui.Button.ClickListener;
  25. import com.vaadin.ui.Panel;
  26. import com.vaadin.ui.VerticalLayout;
  27. import com.vaadin.ui.Window;
  28. /**
  29. * Reproducing bug #12943 where an action on a Button or ComboBox placed at the
  30. * bottom of a window in a scroll panel, will scroll up the parent panel.
  31. *
  32. * This was due to the fact that with the state confirmation notification from
  33. * the server, the window.setVisible would be call again, and the hack that
  34. * solved the scrollbars in a window (#11994) would cause the our bug.
  35. *
  36. * @since
  37. * @author Vaadin Ltd
  38. */
  39. @SuppressWarnings("serial")
  40. public class BottomComponentScrollsUp extends AbstractTestUI {
  41. @Override
  42. protected void setup(VaadinRequest request) {
  43. Button b = new Button("Open window");
  44. addComponent(b);
  45. b.addClickListener(new ClickListener() {
  46. @Override
  47. public void buttonClick(ClickEvent event) {
  48. openWindow();
  49. }
  50. });
  51. openWindow();
  52. }
  53. private void openWindow() {
  54. Window w = new Window();
  55. w.setWidth("300px");
  56. w.setHeight("300px");
  57. w.center();
  58. Panel p = createPanel();
  59. p.setSizeFull();
  60. w.setContent(p);
  61. addWindow(w);
  62. }
  63. private Panel createPanel() {
  64. Panel p = new Panel();
  65. VerticalLayout content = new VerticalLayout();
  66. p.setContent(content);
  67. content.setHeight("500px");
  68. List<String> items = new ArrayList<String>();
  69. items.add("1");
  70. items.add("2");
  71. items.add("3");
  72. Button button = new Button("Press me");
  73. content.addComponent(button);
  74. content.setComponentAlignment(button, Alignment.BOTTOM_CENTER);
  75. return p;
  76. }
  77. @Override
  78. protected String getTestDescription() {
  79. return "Interacting with a component at the bottom of scrollable panel within a subwindow scrolls up";
  80. }
  81. @Override
  82. protected Integer getTicketNumber() {
  83. return 12943;
  84. }
  85. }