New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
consider implementing "autofocus" #136
Comments
Sounds good to me! I think we can add this pretty trivially to app-router. Will we need to do anything to make sure we don't clobber any focus attempts made by the new autofocus custom attribute that was contributed a few weeks back? |
I'm not sure about that. Why hardcode this inside the router when writing an auto-focus custom attribute is trivial (well mostly call It's too bad the HTML5 spec only gives focus to the first |
@EisenbergEffect Thoughts on this? I think I agree with @jods4. If we add support to the router then we probably need to add an API for disabling it. I'm not sure it's worth the complication. |
Couple thoughts:
|
I am not sure I see the alternative. Inserting multiple Although I never encountered this problem in practice (I use my own Do you have use cases in mind where things would get hairy? My typical use of |
@jods4 take a look at the original post for this issue. It describes how durandal used the This is an important and extremely common scenario that I feel should be covered or at least documented in some way. Having a prescribed focus strategy will help developers make their apps more accessible and help devs avoid pitfalls like the race conditions that can arise with the custom attribute approach. Another scenario is when using aurelia-dialog, when the modal is popped the focus remains on the original screen and you can tab off the modal and onto the page below. The bootstrap modal enforces a rule where the modal gets the focus when it's popped and users cannot tab off the modal into the background. Come to think of it, we should probably make whatever we do here (if anything) consistent with what is done here: aurelia/dialog#1 If there's no appetite to add this behavior to aurelia I can look into providing it with a plugin. |
I agree with you that it's important. I think implementation-wise I just don't see what's so bad with the
Now, the thing about preventing tabbing off is a totally different issue I think. And probably an important one. Let's be honest: in today's browsers tab control is not good. Escaping a "modal" dialog is most of the time possible and a bad thing.
|
I agree that we shouldn't implement something that may not be flexible enough. In my own apps I prefer not to return the Promise from The router also has no DOM references right now, and I'd love to keep it that way :-) @jdanyow Would you be happy to push this feature into a plugin? |
good points- closing |
For the sake of use-cases that could be interesting tests: Today I built a dynamic list in a form, with a complex template and an add button. The list itself is simply a For this I used an |
The Durandal dialog plugin had a feature where it would find the first
.autofocus
element and focus it. Code for this is here.In Durandal, this behavior didn't extend to standard (non-modal) routing scenarios but it could easily be added by doing something like this:
Should we consider adding this functionality to Aurelia's router?
Another possibly relevant link: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms_in_HTML#The_autofocus_attribute
The text was updated successfully, but these errors were encountered: