about summary refs log tree commit diff
path: root/app/javascript/core/settings.js
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-04-04 14:53:52 +0200
committerThibaut Girka <thib@sitedethib.com>2019-04-04 14:53:52 +0200
commit1682ac571763f473da54074b0608cd9ccb4b9ae5 (patch)
tree2cb3f134660b2d7d460772966f7eb595395611f7 /app/javascript/core/settings.js
parent3f5acc1ab3bc9c5a6c5805901a393ccd3457b909 (diff)
parent26bd9fa508ac155f996c2c0d9753a27d46158749 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- app/controllers/following_accounts_controller.rb
  Conflicts were due to glitch-soc's theming system.
- app/javascript/packs/public.js
  Some code has been change upstream, but it has been
  moved to app/javascript/core/settings.js in glitch-soc.
  Applied the changes there.
Diffstat (limited to 'app/javascript/core/settings.js')
-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;
 });