mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 19:23:37 +08:00
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 {
|
export default class AutoFocusModifier extends Modifier {
|
||||||
didFocus = false;
|
didFocus = false;
|
||||||
|
|
||||||
modify(element) {
|
modify(element, _, { selectText }) {
|
||||||
if (!this.didFocus) {
|
if (!this.didFocus) {
|
||||||
element.autofocus = true;
|
element.autofocus = true;
|
||||||
element.focus();
|
element.focus();
|
||||||
|
|
||||||
|
if (selectText) {
|
||||||
|
element.select();
|
||||||
|
}
|
||||||
|
|
||||||
this.didFocus = true;
|
this.didFocus = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user