angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

add $hasFocus or $focused to forms

Open IgorMinar opened this issue 14 years ago • 25 comments

just like we have $pristine and $dirty it would be great if we also allowed binding to $focus and $notFocused.

IgorMinar avatar Apr 24 '12 23:04 IgorMinar

+1

mpaulucci avatar Oct 23 '12 18:10 mpaulucci

+1 :+1: Already implemented in my app :)

celmaun avatar Nov 30 '12 15:11 celmaun

As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months.

Please try the newest versions of Angular (1.0.8 and 1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.

Thanks!

btford avatar Aug 24 '13 00:08 btford

Unless I'm reading the docs wrong, this is still an issue.

thauber avatar Nov 21 '13 22:11 thauber

You can just use ngFocus: http://docs.angularjs.org/api/ng.directive:ngFocus

Not sure you really need this.

btford avatar Nov 21 '13 23:11 btford

Yes we do. Otherwise why would we need $dirty or $valid? We could handle those by some custom directives. But this is not what angular is about. So I think form.$focused is definitively needed.

LukeSkyw avatar Jul 17 '14 18:07 LukeSkyw

+1

turquoiseowl avatar Oct 08 '14 12:10 turquoiseowl

+1

Jakobovski avatar Oct 09 '14 18:10 Jakobovski

+1 This is definitely needed. Consider the situation:

<div class="input-group">
        <input ng-model="formname.fieldname.val" name="fieldname" />

        <span class="input-group-addon">
              <i class="glyphicon glyphicon-time"></i>
        </span>
 </div>

I can do:

input:focus + .input-group-addon .glyphicon { color: $focusColor; }

But I cannot do this if I want the icon-group-addon before the input. $focus flag on form models would solve this.

<div class="input-group">
       <span class="input-group-addon">
              <i class="glyphicon glyphicon-time" 
                 ng-class="{ 'focus': formname.fieldname.$focus }"></i>
        </span>
        <input ng-model="formname.fieldname.val" name="fieldname" />        
 </div>

parliament718 avatar Oct 24 '14 20:10 parliament718

+1

wub avatar Nov 24 '15 02:11 wub

+1

danmoc avatar Mar 03 '16 08:03 danmoc

+1

tomjwilliamson avatar Mar 11 '16 12:03 tomjwilliamson

+1

Consider situation where error "This field does not pass validation" is shown even when input is focus. User would be annoyed seeing the error message as he's intending to enter the right text.

poonwu avatar Mar 22 '16 12:03 poonwu

@poonwu, this is what .ng-touched/ng-untouched are for (although not exactly the same as focus). A focus specific class might indeed be needed in some applications, but we don't want to clutter the core with stuff that may be unused by most. Especially since this is trivial to implement outside of core.

gkalpak avatar Mar 22 '16 12:03 gkalpak

+1 I agree that it would still be useful. Similar to what @poonwu mentions - Many use cases exist where one may want to show validation-specific messages or styles for fields once $touched is true, but only if the field does not have focus. $focused would certainly help.

agscheidle avatar Apr 14 '16 21:04 agscheidle

+1

anmarcek avatar Nov 08 '16 12:11 anmarcek

+1 - this flag can definitely come useful in many cases.

dmaster7 avatar Dec 27 '16 22:12 dmaster7

+1

camt avatar Mar 20 '17 00:03 camt

+1

johandelforge avatar Mar 26 '17 04:03 johandelforge

@btford Any idea on this one? Or is it gone for good? It seems you've had people chiming in on this for almost 5 years now.

Cheers

wub avatar Mar 26 '17 20:03 wub