Browse Source

Move combo popup opener clicked flag to connector (#19929)

The flag is only used by the connector to temporarily block
certain operations.

Change-Id: I90cabcb26d938a6db342ff549ac2e4b8d8998aeb
feature/eventbus
Henri Sara 8 years ago
parent
commit
0ae76fe0a3

+ 3
- 31
client/src/main/java/com/vaadin/client/ui/VFilterSelect.java View File

@@ -1467,10 +1467,10 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
public String selectedOptionKey;

/** For internal use only. May be removed or replaced in the future. */
public boolean waitingForFilteringResponse = false;
private boolean waitingForFilteringResponse = false;

/** For internal use only. May be removed or replaced in the future. */
public boolean updateSelectionWhenReponseIsReceived = false;
private boolean updateSelectionWhenReponseIsReceived = false;

/** For internal use only. May be removed or replaced in the future. */
public boolean initDone = false;
@@ -1517,15 +1517,6 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
/** For internal use only. May be removed or replaced in the future. */
public boolean prompting = false;

/**
* Set true when popupopened has been clicked. Cleared on each UIDL-update.
* This handles the special case where are not filtering yet and the
* selected value has changed on the server-side. See #2119
* <p>
* For internal use only. May be removed or replaced in the future.
*/
public boolean popupOpenerClicked;

/** For internal use only. May be removed or replaced in the future. */
public int suggestionPopupMinWidth = 0;

@@ -2205,7 +2196,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
boolean immediate = focused
|| !connector.hasEventListener(EventId.FOCUS);
filterOptions(-1, "", immediate);
setPopupOpenerClicked(true);
connector.popupOpenerClicked();
lastFilter = "";
}
DOM.eventPreventDefault(DOM.eventGetCurrentEvent());
@@ -2591,23 +2582,4 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
this.updateSelectionWhenReponseIsReceived = updateSelectionWhenReponseIsReceived;
}

/**
* For internal use only - this method will be removed in the future.
*
* @return true if the user has requested opening the popup
*/
public boolean isPopupOpenerClicked() {
return popupOpenerClicked;
}

/**
* For internal use only - this method will be removed in the future.
*
* @param popupOpenerClicked
* true if the user has requested opening the popup
*/
public void setPopupOpenerClicked(boolean popupOpenerClicked) {
this.popupOpenerClicked = popupOpenerClicked;
}

}

+ 27
- 5
client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java View File

@@ -56,6 +56,15 @@ public class ComboBoxConnector extends AbstractFieldConnector implements

private Runnable pageChangeCallback;

/**
* Set true when popupopened has been clicked. Cleared on each UIDL-update.
* This handles the special case where are not filtering yet and the
* selected value has changed on the server-side. See #2119
* <p>
* For internal use only. May be removed or replaced in the future.
*/
private boolean popupOpenerClicked;

@Override
protected void init() {
super.init();
@@ -223,7 +232,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements

getWidget().setWaitingForFilteringResponse(false);

if (!getWidget().isPopupOpenerClicked()) {
if (!popupOpenerClicked) {
navigateItemAfterPageChange();
}

@@ -236,7 +245,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
// Calculate minimum textarea width
getWidget().updateSuggestionPopupMinWidth();

getWidget().setPopupOpenerClicked(false);
popupOpenerClicked = false;

/*
* if this is our first time we need to recalculate the root width.
@@ -289,7 +298,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
continue;
}
if (!getWidget().isWaitingForFilteringResponse()
|| getWidget().isPopupOpenerClicked()) {
|| popupOpenerClicked) {
if (!suggestionKey.equals(getWidget().selectedOptionKey)
|| suggestion.getReplacementString().equals(
getWidget().tb.getText())
@@ -318,8 +327,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
}

private void resetSelection() {
if (!getWidget().isWaitingForFilteringResponse()
|| getWidget().isPopupOpenerClicked()) {
if (!getWidget().isWaitingForFilteringResponse() || popupOpenerClicked) {
// select nulled
if (!getWidget().focused) {
/*
@@ -500,4 +508,18 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
pageChangeCallback = null;
}

/**
* Record that the popup opener has been clicked and the popup should be
* opened on the next request.
*
* This handles the special case where are not filtering yet and the
* selected value has changed on the server-side. See #2119. The flag is
* cleared on each UIDL reply.
*
* @since
*/
public void popupOpenerClicked() {
popupOpenerClicked = true;
}

}

Loading…
Cancel
Save