question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I 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:closed
  • Created 8 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
perluncommented, Apr 12, 2018

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

0reactions
cibernoxcommented, May 6, 2018

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found