DEV: Add selectText option to auto-focus modifier (#24458)

This commit is contained in:
Jarek Radosz 2023-11-20 14:53:20 +01:00 committed by GitHub
parent c5affa9ca2
commit 1a43010603
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -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;
}
}