From 310e08dc2cd743952ef9a6f3bf7300448147dc77 Mon Sep 17 00:00:00 2001
From: Stan Hu <stanhu@gmail.com>
Date: Sun, 24 May 2015 09:00:00 -0400
Subject: [PATCH] Fix clone URL losing selection after a single click in Safari
 and Chrome

Closes #9326
---
 CHANGELOG                                    | 1 +
 app/assets/javascripts/application.js.coffee | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index d1ecfb40350..45e2ee0eb74 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 Please view this file on the master branch, on stable branches it's out of date.
 
 v 7.12.0 (unreleased)
+  - Fix clone URL losing selection after a single click in Safari and Chrome (Stan Hu)
   - Allow to configure location of the `.gitlab_shell_secret` file. (Jakub Jirutka)
   - Disabled expansion of top/bottom blobs for new file diffs
   - Update Asciidoctor gem to version 1.5.2. (Jakub Jirutka)
diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee
index caf18c0d860..ea2a4b97101 100644
--- a/app/assets/javascripts/application.js.coffee
+++ b/app/assets/javascripts/application.js.coffee
@@ -116,7 +116,10 @@ window.addEventListener "hashchange", shiftWindow
 
 $ ->
   # Click a .js-select-on-focus field, select the contents
-  $(".js-select-on-focus").on "focusin", -> $(this).select()
+  $(".js-select-on-focus").on "focusin", ->
+    # Prevent a mouseup event from deselecting the input
+    $(this).select().one 'mouseup', (e) ->
+      e.preventDefault()
 
   $('.remove-row').bind 'ajax:success', ->
     $(this).closest('li').fadeOut()
-- 
2.30.9