DEV: Add selectText option to auto-focus modifier (#24458)
This commit is contained in:
parent
c5affa9ca2
commit
1a43010603
|
@ -3,11 +3,15 @@ import Modifier from "ember-modifier";
|
|||
export default class AutoFocusModifier extends Modifier {
|
||||
didFocus = false;
|
||||
|
||||
modify(element) {
|
||||
modify(element, _, { selectText }) {
|
||||
if (!this.didFocus) {
|
||||
element.autofocus = true;
|
||||
element.focus();
|
||||
|
||||
if (selectText) {
|
||||
element.select();
|
||||
}
|
||||
|
||||
this.didFocus = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue