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

add $hasFocus or $focused to forms #903

Closed

Description

@IgorMinar

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

Activity

  1. mpaulucci commented on Oct 23, 2012

    @mpaulucci

    +1

  2. celmaun commented on Nov 30, 2012

    @celmaun

    +1 👍 Already implemented in my app :)

  3. btford commented on Aug 24, 2013

    @btford
    Contributor

    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!

  4. thauber commented on Nov 21, 2013

    @thauber

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

  5. btford commented on Nov 21, 2013

    @btford
    Contributor

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

    Not sure you really need this.

  6. LukeSkyw commented on Jul 17, 2014

    @LukeSkyw

    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.

  7. turquoiseowl commented on Oct 8, 2014

    @turquoiseowl

    +1

  8. Jakobovski commented on Oct 9, 2014

    @Jakobovski

    +1

  9. parliament718 commented on Oct 24, 2014

    @parliament718

    +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>
    
  10. wub commented on Nov 24, 2015

    @wub

    +1

  11. danmoc commented on Mar 3, 2016

    @danmoc

    +1

  12. tomjwilliamson commented on Mar 11, 2016

    @tomjwilliamson

    +1

  13. poonwu commented on Mar 22, 2016

    @poonwu

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

  14. gkalpak commented on Mar 22, 2016

    @gkalpak
    Member

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

  15. agscheidle commented on Apr 14, 2016

    @agscheidle

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

  16. anmarcek commented on Nov 8, 2016

    @anmarcek

    +1

  17. dmaster7 commented on Dec 27, 2016

    @dmaster7

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

  18. camt commented on Mar 20, 2017

    @camt

    +1

  19. johandelforge commented on Mar 26, 2017

    @johandelforge

    +1

  20. wub commented on Mar 26, 2017

    @wub

    @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

  21. gkalpak commented on Mar 27, 2017

    @gkalpak
    Member

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

  22. SarikaVanapalli commented on Apr 19, 2017

    @SarikaVanapalli

    +1

  23. sidhujaspreet commented on Sep 26, 2017

    @sidhujaspreet

    +1

  24. keremkayhan commented on Oct 16, 2017

    @keremkayhan

    +1

  25. r0ssIV commented on Feb 27, 2018

    @r0ssIV

    +1
    Damn, they don't undserstand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions