From 1a43010603a0b822eab5bcfd1df29790d4437af6 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Mon, 20 Nov 2023 14:53:20 +0100 Subject: [PATCH] DEV: Add selectText option to auto-focus modifier (#24458) --- .../javascripts/discourse/app/modifiers/auto-focus.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/modifiers/auto-focus.js b/app/assets/javascripts/discourse/app/modifiers/auto-focus.js index e1e75fd721f..1d0f5a3516d 100644 --- a/app/assets/javascripts/discourse/app/modifiers/auto-focus.js +++ b/app/assets/javascripts/discourse/app/modifiers/auto-focus.js @@ -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; } }