demarches-normaliennes/app/javascript/controllers/autofocus_controller.ts

10 lines
255 B
TypeScript
Raw Normal View History

import { Controller } from '@hotwired/stimulus';
export class AutofocusController extends Controller {
connect() {
const element = this.element as HTMLInputElement;
element.focus();
element.setSelectionRange(0, element.value.length);
}
}