Autofocus
See original GitHub issueI am trying to implement an autofocus attribute feature, so when it renders and I add an autofocus attribute, my power select will automatically be open and have the cursor ready to go
Here is my power select
{{#power-select renderInPlace=true selected=productSelected
search=(action "searchForProducts") allowClear=true
placeholder="Search for Product" onchange=(action (mut productSelected))
onfocus=(action "selectFocused") class="product-select"
autofocus="autofocus"
as |item|}}
{{item.name}}
{{/power-select}}
I was playing around with this, but I can’t quite figure out how to force the power select to open. Do you know of a solution that would work?
import Ember from 'ember';
import EmberPowerSelect from 'ember-power-select/components/power-select';
export function initialize(/* application */) {
EmberPowerSelect.reopen({
didInsertElement: function() {
this._super(...arguments);
Ember.run.next(() => {}
if (this.get('autofocus')) {
}
});
}
});
}
export default {
name: 'power-select',
initialize
};
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Autofocus - Wikipedia
An autofocus (or AF) optical system uses a sensor, a control system and a motor to focus on an automatically or manually selected...
Read more >autofocus - HTML: HyperText Markup Language | MDN
The autofocus global attribute is a Boolean attribute indicating that an element should be focused on page load, or when the <dialog> that ......
Read more >HTML input autofocus Attribute - W3Schools
The autofocus attribute is a boolean attribute. When present, it specifies that an <input> element should automatically get focus when the page loads....
Read more >AUTO FOCUS – Car Dealer in Greensboro, NC
M-F: 8am - 6pm. Sat: 10am - 2pm - By Appointment Sun: Closed. PHONE (336) 852-5852. 5316 W MARKET ST | Greensboro, NC...
Read more >Auto Focus - YouTube
Auto Focus. Auto Focus. @AutoFocus. @AutoFocus 473K subscribers 12 videos. Subscribe. Home. Videos. Playlists. Community. Channels.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@cibernox This has been disturbing me for a while, and today I found this issue.
Would it make sense if we added this to the public API? Being able to automatically give focus to “the most important form field” in a form is IMHO good practice, and will improve the user experience greatly for certain (app-like) web pages & web apps.
@lougreenwood The problem is that autofocus is an html attributes that only works on native inputs, textareas and selects. EPS is not a real select and AFAIK it’s impossible to replicate it reliably. Focusing the select on
didInsertElement
is the closest we can get, but in reality it is more complex than that, that’s why I am reluctant to implement it that way.