File tree Expand file tree Collapse file tree 1 file changed +29
-2
lines changed
gwt-material/src/main/java/gwt/material/design/client/ui Expand file tree Collapse file tree 1 file changed +29
-2
lines changed Original file line number Diff line number Diff line change 11package 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
You can’t perform that action at this time.
0 commit comments