Skip to content

Commit bd4fe36

Browse files
committed
Merge pull request ArcBees#289 from ArcBees/jl_mobileMultipleFixPlaceholder
Fix placeholder on mobile multiple
2 parents 2f547d0 + 7ee4e5c commit bd4fe36

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

plugin/src/main/java/com/arcbees/chosen/client/ChosenImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ public abstract class ChosenImpl {
8787
protected boolean resultsShowing;
8888
protected GQuery searchChoices;
8989
protected GQuery searchContainer;
90+
protected String defaultText;
9091
private GQuery $selectElement;
9192
private boolean allowSingleDeselect;
9293
private GQuery container;
9394
private String containerId;
9495
private ChosenCss css;
9596
private List<String> selectedValues = new ArrayList<String>();
96-
private String defaultText;
9797
private GQuery dropdown;
9898
private EventBus eventBus;
9999
private int fWidth;

plugin/src/main/java/com/arcbees/chosen/client/DesktopMultipleChosenImpl.java

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ protected StringBuilder buildOptionStyleClass(OptionItem option) {
8484
return classes;
8585
}
8686

87+
@Override
8788
protected void addChoice(OptionItem option) {
8889
if (maxSelectedOptionsReached()) {
8990
fireEvent(new MaxSelectedEvent(this));

plugin/src/main/java/com/arcbees/chosen/client/MobileMultipleChosenImpl.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
import com.arcbees.chosen.client.SelectParser.OptionItem;
2020
import com.arcbees.chosen.client.event.MaxSelectedEvent;
2121
import com.google.gwt.dom.client.OptionElement;
22+
import com.google.gwt.dom.client.SelectElement;
2223
import com.google.gwt.query.client.GQuery;
2324
import com.google.gwt.user.client.Event;
25+
import com.google.web.bindery.event.shared.EventBus;
2426

2527
public class MobileMultipleChosenImpl extends AbstractMobileChosenImpl {
2628
@Override
@@ -48,6 +50,7 @@ protected void addChoice(OptionItem item) {
4850
}
4951
}
5052

53+
@Override
5154
protected void resultDeactivate(GQuery query, boolean selected) {
5255
if (!selected) {
5356
super.resultDeactivate(query, selected);
@@ -87,6 +90,13 @@ protected void update() {
8790
closeField();
8891
}
8992

93+
@Override
94+
protected void init(SelectElement element, ChosenOptions options, EventBus eventBus) {
95+
super.init(element, options, eventBus);
96+
97+
updateSelectedText();
98+
}
99+
90100
private void resultDeselect(OptionItem item, GQuery element) {
91101
choices--;
92102

@@ -111,8 +121,10 @@ private void updateSelectedText() {
111121
String selectedText;
112122
if (choices > 1) {
113123
selectedText = getOptions().getManySelectedTextMultipleMobile();
114-
} else {
124+
} else if (choices == 1) {
115125
selectedText = getOptions().getOneSelectedTextMultipleMobile();
126+
} else {
127+
selectedText = defaultText;
116128
}
117129

118130
selectedText = selectedText.replace("{}", "" + choices);

0 commit comments

Comments
 (0)