Skip to content
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

Modal autofocus option doesn't work #2737

Closed
azazel75 opened this issue Jul 28, 2015 · 9 comments
Closed

Modal autofocus option doesn't work #2737

azazel75 opened this issue Jul 28, 2015 · 9 comments
Milestone

Comments

@azazel75
Copy link

The paramenter "autofocus" for the modal() module has no effect.
I have a modal dialog with a login form inside and and none of the input fields gets focused after show.

The code of modal.js reveals that the problem seems to be the use of $module.filter(':input') to select the input elements. In my case $module is the jquery-wrapped "div" containing all the dialog contents and filter's job is to filter an array of elements by applying a selector to them, not that of "finding" child elements.

@jlukic
Copy link
Member

jlukic commented Jul 28, 2015

This code is just wrong. Thanks for the report, and sorry about that.

jlukic added a commit that referenced this issue Jul 28, 2015
… to outside function so it can be called manually
jlukic added a commit that referenced this issue Jul 28, 2015
@davialexandre
Copy link
Contributor

What about making this autofocus feature more flexible by allowing it to receive a boolean or a function/callback that would set the focus?

I am thinking about scenarios where I wouldn't want to the set focus on the first input or where my first field isn't exactly an input (e.g a select2 dropdown).

@azazel75
Copy link
Author

You always have the "show" action callback to perform more complex tasks that's the one i'm using now to focus the first input. By the way, are you sure $(':input') doesn't match a select2 dropdown. I've tried here https://select2.github.io/examples.html but without a clear answer

@jlukic
Copy link
Member

jlukic commented Jul 28, 2015

But we have a multi select 😄

In all seriousness, I think using callbacks and custom logic makes sense.

@jlukic jlukic added this to the 2.1 milestone Jul 28, 2015
@jlukic jlukic closed this as completed Jul 28, 2015
@davialexandre
Copy link
Contributor

Right now I am using the show action callback for this, but it doesn't seems quite "right" to me. Also it took me sometime to figure I could pass a callback to it, since there's no example of this in the documentation.

Maybe something with an onVisible callback would make more sense, but it will be called before autofocus :(

@davialexandre
Copy link
Contributor

@jlukic multi select currently doesn't have all the features I need :(

@jlukic
Copy link
Member

jlukic commented Jul 28, 2015

What features are missing?

@davialexandre
Copy link
Contributor

I created an issue about they: #2746

@bianjp
Copy link

bianjp commented Aug 15, 2015

Met the problem. Hope 2.1 will come soon.

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

No branches or pull requests

4 participants