From cb53e48a5830ab845beafa31491bd8b9e4ff1605 Mon Sep 17 00:00:00 2001 From: Steven Bull Date: Thu, 23 Feb 2012 11:23:04 -0800 Subject: [PATCH] Don't setPlaceholder if the element has focus. Fixes #56. --- jquery.placeholder.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jquery.placeholder.js b/jquery.placeholder.js index a0c00f5..6360550 100644 --- a/jquery.placeholder.js +++ b/jquery.placeholder.js @@ -45,8 +45,11 @@ } if (value == '') { element.value = value; - // We can’t use `triggerHandler` here because of dummy text/password inputs :( - setPlaceholder.call(element); + // Issue #56: Setting the placeholder causes problems if the element continues to have focus. + if (!$element.is(':focus')) { + // We can’t use `triggerHandler` here because of dummy text/password inputs :( + setPlaceholder.call(element); + } } else if ($element.hasClass('placeholder')) { clearPlaceholder.call(element, true, value) || (element.value = value); } else {