Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #591 from jmulieri/master

Resolving Issue #590, 'Hint not working properly for SC.TextFieldView in IE'
  • Loading branch information...
commit c5662c12da98bd7011dd1c887a9e08754a9baa66 2 parents ceaeda4 + b3bb40f
authored
15  frameworks/foundation/tests/views/text_field/ui.js
@@ -623,6 +623,21 @@ test("focus and blurring text field", function() {
623 623
   
624 624
 });
625 625
 
  626
+test("focus and blur an empty text field", function() {
  627
+  var view = pane.view('empty');
  628
+  var input = view.$('input');
  629
+
  630
+  // verify the field is empty and the hint is properly set
  631
+  pane.verifyEmpty(view, 'Full Name');
  632
+
  633
+  // focus and blur the text field
  634
+  SC.Event.trigger(input, 'focus');
  635
+  SC.Event.trigger(input, 'blur');
  636
+
  637
+  // field should still be still be empty with hint properly set
  638
+  pane.verifyEmpty(view, 'Full Name');
  639
+});
  640
+
626 641
 test("editing a field should not change the cursor position", function() {
627 642
   var textField = pane.view('empty');
628 643
   var input = textField.$('input');
6  frameworks/foundation/views/text_field.js
@@ -602,6 +602,7 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
602 602
 
603 603
           if (!SC.platform.input.placeholder) {
604 604
             context.setClass('sc-hint', YES);
  605
+            input.val(hint);
605 606
           }
606 607
         } else {
607 608
           // Internet Explorer doesn't allow you to modify the type afterwards
@@ -771,7 +772,7 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
771 772
       this.set('focused',YES);
772 773
       this.fieldDidFocus(evt);
773 774
       var val = this.get('value');
774  
-      if(!SC.platform.input.placeholder && ((!val) || (val && val.length===0))) {
  775
+      if(!SC.platform.input.placeholder && ((!val) || (val && val.length===0) || (val && val == this.hint))) {
775 776
         this._hintON = NO;
776 777
       }
777 778
     }, this);
@@ -790,8 +791,9 @@ SC.TextFieldView = SC.FieldView.extend(SC.StaticLayout, SC.Editable,
790 791
       this.fieldDidBlur(this._origEvent || evt);
791 792
 
792 793
       var val = this.get('value');
793  
-      if(!SC.platform.input.placeholder && ((!val) || (val && val.length===0))) {
  794
+      if(!SC.platform.input.placeholder && !this._hintON && ((!val) || (val && val.length===0))) {
794 795
         this._hintON = YES;
  796
+        this.updateLayer();
795 797
       }
796 798
     }, this);
797 799
   },

0 notes on commit c5662c1

Please sign in to comment.
Something went wrong with that request. Please try again.