Skip to content

Commit 021fa46

Browse files
committed
Merge pull request #342 from vegegoku/master
issue #317
2 parents 7eb2738 + 907dfc3 commit 021fa46

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

gwt-material/src/main/java/gwt/material/design/client/ui/MaterialValueBox.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package gwt.material.design.client.ui;
22

3+
import com.google.gwt.core.client.Scheduler;
4+
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
5+
36
/*
47
* #%L
58
* GwtMaterial
@@ -530,8 +533,32 @@ public void setAccessKey(char key) {
530533
}
531534

532535
@Override
533-
public void setFocus(boolean focused) {
534-
valueBoxBase.setFocus(focused);
536+
public void setFocus(final boolean focused) {
537+
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
538+
539+
@Override
540+
public void execute() {
541+
valueBoxBase.setFocus(focused);
542+
if (focused) {
543+
label.addStyleName("active");
544+
} else {
545+
updateLabelActiveStyle();
546+
}
547+
}
548+
});
549+
}
550+
551+
/**
552+
* Updates the style of the field label according to the field value if the
553+
* field value is empty - null or "" - removes the label 'active' style else
554+
* will add the 'active' style to the field label.
555+
*/
556+
private void updateLabelActiveStyle() {
557+
if (this.valueBoxBase.getText() != null && !this.valueBoxBase.getText().isEmpty()) {
558+
label.addStyleName("active");
559+
} else {
560+
label.removeStyleName("active");
561+
}
535562
}
536563

537564
@Override

0 commit comments

Comments
 (0)