about summary refs log tree commit diff
path: root/app/javascript/core
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/core')
-rw-r--r--app/javascript/core/settings.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/javascript/core/settings.js b/app/javascript/core/settings.js
index af97fb25f..e0cb944e0 100644
--- a/app/javascript/core/settings.js
+++ b/app/javascript/core/settings.js
@@ -42,14 +42,20 @@ delegate(document, '#account_locked', 'change', ({ target }) => {
 });
 
 delegate(document, '.input-copy input', 'click', ({ target }) => {
+  target.focus();
   target.select();
+  target.setSelectionRange(0, target.value.length);
 });
 
 delegate(document, '.input-copy button', 'click', ({ target }) => {
   const input = target.parentNode.querySelector('.input-copy__wrapper input');
 
+  const oldReadOnly = input.readonly;
+
+  input.readonly = false;
   input.focus();
   input.select();
+  input.setSelectionRange(0, input.value.length);
 
   try {
     if (document.execCommand('copy')) {
@@ -63,4 +69,6 @@ delegate(document, '.input-copy button', 'click', ({ target }) => {
   } catch (err) {
     console.error(err);
   }
+
+  input.readonly = oldReadOnly;
 });