Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

add $hasFocus or $focused to forms #903

Closed
IgorMinar opened this issue Apr 24, 2012 · 25 comments
Closed

add $hasFocus or $focused to forms #903

IgorMinar opened this issue Apr 24, 2012 · 25 comments

Comments

@IgorMinar
Copy link
Contributor

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

@mpaulucci
Copy link

+1

@celmaun
Copy link

celmaun commented Nov 30, 2012

+1 👍 Already implemented in my app :)

@btford
Copy link
Contributor

btford commented Aug 24, 2013

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!

@thauber
Copy link

thauber commented Nov 21, 2013

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

@btford
Copy link
Contributor

btford commented Nov 21, 2013

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

Not sure you really need this.

@LukeSkyw
Copy link

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.

@turquoiseowl
Copy link

+1

1 similar comment
@Jakobovski
Copy link

+1

@parliament718
Copy link

+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>

@wub
Copy link

wub commented Nov 24, 2015

+1

2 similar comments
@danmoc
Copy link

danmoc commented Mar 3, 2016

+1

@tomjwilliamson
Copy link

+1

@poonwu
Copy link

poonwu commented Mar 22, 2016

+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.

@gkalpak
Copy link
Member

gkalpak commented Mar 22, 2016

@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.

@agscheidle
Copy link

+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.

@anmarcek
Copy link

anmarcek commented Nov 8, 2016

+1

@dmaster7
Copy link

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

@camt
Copy link

camt commented Mar 20, 2017

+1

1 similar comment
@joSFD
Copy link

joSFD commented Mar 26, 2017

+1

@wub
Copy link

wub commented Mar 26, 2017

@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

@gkalpak
Copy link
Member

gkalpak commented Mar 27, 2017

As explained in #903 (comment), I still believe this is not something that belongs in core. It is not as often needed and is pretty easy to implement as a standalone directive (and even distribute as a 3rd-party module). Especially since Angular (2+) doesn't support it either afaik, I would be very hesitant about adding it to AngularJS (1.x).

@SarikaVanapalli
Copy link

+1

1 similar comment
@sidhujaspreet
Copy link

+1

@keremkayhan
Copy link

+1

@r0ssIV
Copy link

r0ssIV commented Feb 27, 2018

+1
Damn, they don't undserstand.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests