Bladeren bron

Fixed regression with changing widths when stylenames have changed (#13444, #8801):

Changing the name of a style should not cause the width of the textbox
to change. If there is a width set for the wrapper, the width for the
wrapper should not change if the styles changes.

To reconcile these two demands, we have removed the width for the
wrapper and only manipulate the width of the textbox itself. This
solves both issues neatly.

Change-Id: Idb2dbc5d2ca6406cafb44df93110e079a1dff473

Conflicts:
	client/src/com/vaadin/client/ui/VFilterSelect.java
	client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
tags/7.2.6
Markus Koivisto 10 jaren geleden
bovenliggende
commit
d45e5c2592

+ 46
- 31
client/src/com/vaadin/client/ui/VFilterSelect.java Bestand weergeven

@@ -81,7 +81,7 @@ import com.vaadin.shared.ui.combobox.FilteringMode;

/**
* Client side implementation of the Select component.
*
*
* TODO needs major refactoring (to be extensible etc)
*/
@SuppressWarnings("deprecation")
@@ -101,7 +101,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Constructor
*
*
* @param uidl
* The UIDL recieved from the server
*/
@@ -150,7 +150,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Get the option key which represents the item on the server side.
*
*
* @return The key of the item
*/
public String getOptionKey() {
@@ -159,7 +159,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Get the URI of the icon. Used when constructing the displayed option.
*
*
* @return
*/
public String getIconUri() {
@@ -253,7 +253,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Shows the popup where the user can see the filtered options
*
*
* @param currentSuggestions
* The filtered suggestions
* @param currentPage
@@ -336,7 +336,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Should the next page button be visible to the user?
*
*
* @param active
*/
private void setNextButtonActive(boolean active) {
@@ -356,7 +356,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Should the previous page button be visible to the user
*
*
* @param active
*/
private void setPrevButtonActive(boolean active) {
@@ -411,7 +411,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Select the first item of the suggestions list popup.
*
*
* @since
*/
public void selectFirstItem() {
@@ -421,7 +421,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Select the last item of the suggestions list popup.
*
*
* @since
*/
public void selectLastItem() {
@@ -547,7 +547,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
* amount of items are visible at a time and a scrollbar or buttons are
* visible to change page. If paging is turned of then all options are
* rendered into the popup menu.
*
*
* @param paging
* Should the paging be turned on?
*/
@@ -672,7 +672,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Was the popup just closed?
*
*
* @return true if popup was just closed
*/
public boolean isJustClosed() {
@@ -701,7 +701,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Updates style names in suggestion popup to help theme building.
*
*
* @param uidl
* UIDL for the whole combo box
* @param componentState
@@ -792,7 +792,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Sets the suggestions rendered in the menu
*
*
* @param suggestions
* The suggestions to be rendered in the menu
*/
@@ -1039,7 +1039,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
/**
* TextBox variant used as input element for filter selects, which prevents
* selecting text when disabled.
*
*
* @since 7.1.5
*/
public class FilterSelectTextBox extends TextBox {
@@ -1291,7 +1291,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
* It is invoked during the Constructor and should only be overridden if a
* custom TextBox shall be used. The overriding method cannot use any
* instance variables.
*
*
* @since 7.1.5
* @return TextBox instance used by this VFilterSelect
*/
@@ -1304,7 +1304,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
* instance. It is invoked during the Constructor and should only be
* overridden if a custom SuggestionPopup shall be used. The overriding
* method cannot use any instance variables.
*
*
* @since 7.1.5
* @return SuggestionPopup instance used by this VFilterSelect
*/
@@ -1332,7 +1332,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Does the Select have more pages?
*
*
* @return true if a next page exists, else false if the current page is the
* last page
*/
@@ -1347,7 +1347,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
/**
* Filters the options at a certain page. Uses the text box input as a
* filter
*
*
* @param page
* The page which items are to be filtered
*/
@@ -1357,7 +1357,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Filters the options at certain page using the given filter
*
*
* @param page
* The page to filter
* @param filter
@@ -1369,7 +1369,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Filters the options at certain page using the given filter
*
*
* @param page
* The page to filter
* @param filter
@@ -1436,7 +1436,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Sets the text in the text box.
*
*
* @param text
* the text to set in the text box
*/
@@ -1465,7 +1465,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
* shown in the text box if nothing has been entered.
* <p>
* For internal use only. May be removed or replaced in the future.
*
*
* @param text
* The text the text box should contain.
*/
@@ -1480,7 +1480,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Triggered when a suggestion is selected
*
*
* @param suggestion
* The suggestion that just got selected.
*/
@@ -1523,7 +1523,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
/**
* Sets the icon URI of the selected item. The icon is shown on the left
* side of the item caption text. Set the URI to null to remove the icon.
*
*
* @param iconUri
* The URI of the icon
*/
@@ -1649,7 +1649,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Triggered when a key is pressed in the text box
*
*
* @param event
* The KeyDownEvent
*/
@@ -1694,7 +1694,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Triggered when a key was pressed in the suggestion popup.
*
*
* @param event
* The KeyDownEvent of the key
*/
@@ -1790,7 +1790,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Triggered when a key was depressed
*
*
* @param event
* The KeyUpEvent of the key depressed
*/
@@ -2073,6 +2073,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
public void updateRootWidth() {
ComponentConnector paintable = ConnectorMap.get(client).getConnector(
this);

if (paintable.isUndefinedWidth()) {

/*
@@ -2097,11 +2098,25 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
String originalBorder = style.getBorderWidth();
style.setPaddingLeft(0, Unit.PX);
style.setBorderWidth(0, Unit.PX);
int offset = w - Util.getRequiredWidth(this);
style.setProperty("padding", originalPadding);
style.setProperty("borderWidth", originalBorder);

setWidth(suggestionPopupMinWidth + offset + "px");
// Use util.getRequiredWidth instead of getOffsetWidth here

int iconWidth = selectedItemIcon == null ? 0 : Util
.getRequiredWidth(selectedItemIcon);
int buttonWidth = popupOpener == null ? 0 : Util
.getRequiredWidth(popupOpener);

/*
* Instead of setting the width of the wrapper, set the width of
* the combobox. Subtract the width of the icon and the
* popupopener
*/

tb.setWidth((suggestionPopupMinWidth - iconWidth - buttonWidth)
+ "px");

}

/*
@@ -2119,7 +2134,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
/**
* Get the width of the select in pixels where the text area and icon has
* been included.
*
*
* @return The width in pixels
*/
private int getMainWidth() {
@@ -2136,7 +2151,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,

/**
* Handles special behavior of the mouse down event
*
*
* @param event
*/
private void handleMouseDownEvent(Event event) {

+ 5
- 1
client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java Bestand weergeven

@@ -44,7 +44,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements

/*
* (non-Javadoc)
*
*
* @see com.vaadin.client.Paintable#updateFromUIDL(com.vaadin.client.UIDL,
* com.vaadin.client.ApplicationConnection)
*/
@@ -206,7 +206,11 @@ public class ComboBoxConnector extends AbstractFieldConnector implements

getWidget().popupOpenerClicked = false;

/*
* if this is our first time we need to recalculate the root width.
*/
if (!getWidget().initDone) {

getWidget().updateRootWidth();
}


+ 2
- 0
uitest/src/com/vaadin/tests/components/combobox/ComboboxStyleChangeWidthTest.java Bestand weergeven

@@ -21,6 +21,7 @@ import org.junit.Test;

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.ComboBoxElement;
import com.vaadin.tests.tb3.AbstractTB3Test.RunLocally;
import com.vaadin.tests.tb3.MultiBrowserTest;

/**
@@ -30,6 +31,7 @@ import com.vaadin.tests.tb3.MultiBrowserTest;
* @author Vaadin Ltd
*/

@RunLocally()
public class ComboboxStyleChangeWidthTest extends MultiBrowserTest {

@Test

Laden…
Annuleren
Opslaan