formly-js / angular-formly

JavaScript powered forms for AngularJS
http://docs.angular-formly.com
MIT License
2.22k stars 405 forks source link

Disable certain parts of ngModelAttrsTemplateManipulator #604

Closed cudasteve closed 8 years ago

cudasteve commented 8 years ago

This might be a bit of an edge-case, but...

It'd be nice if there was a way to disable certain features of ngModelAttrsTemplateManipulator. The docs have multiple ways of disabling it, but as far as the list of features goes, it's kind of a take-it-all-or-leave-it-all deal.

My particular use case was that I liked all the binding, custom validation, etc. but I needed to disable the addition of the tabindex attribute. With ngModelAttrs (or just adding it to the DOM I think) I could have overridden the tabindex, but I needed to pull it off the element completely. I imagine there are other situations in which someone might want some of the magic without all of it. Perhaps we could pass an object to extras.skipNgModelAttrsManipulator that gives true/false for various feature names, effectively feature-gating the functionality it provides?

By the way, in case anyone's wondering why I couldn't just do tabindex="-1", it was because I was trying to get the focus attribute to work on a custom type where the focus element was not the same as the ng-model element. Plus, it was using a third-party directive where I couldn't go in and manually add formly-focus="true". But I found if I put the ng-model on the outer container, the focus would fall-through to the element that should be focused as long as there were no tabindex attributes above it in the DOM. Although in this case, ng-aria would have added the tabindex as well, so it gets pretty messy. Ultimately, I just worked around it, but I think it demonstrates a situation where it'd be nice to break down the all-or-nothing.

kentcdodds commented 8 years ago

I really think that you could find another way to accomplish what you're trying to do. Could you create an example of what you're trying to do following these instructions?

Either way, I don't think that we'll be doing anything significant to change the behavior of the ngModelAttrsTemplateManipulator and I'm sure that we can figure out another way to do what you're trying to do. So I'll go ahead and close this issue. Good luck!