Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Google Chrome(v17) not clearing placeholder text #51

Closed
Gavrisimo opened this Issue Feb 9, 2012 · 7 comments

Comments

Projects
None yet
4 participants

Look here:

http://jsbin.com/oqabum

I had no idea where else to submit this and i didn't find any info about this, but it seems Chrome is not clearing placeholder text when field gets focused.

I have tested all browsers that are available to me on browserstack.com and also Chromium and Firefox on Linux Mint.

Results:

  1. windows:
    • latest versions of Firefox, Opera, Safari and Chrome 16 are clearing placeholder text on focus event
    • Chrome 17 is not clearing placeholder text on focus event
  2. mac:
    • latest versions of Firefox, Safari, Opera and Chrome 16 are clearing placeholder text on focus event
    • Chrome 17 beta is not clearing placeholder text on focus event
  3. linux:
    • Firefox 10 is clearing placeholder text on focus event
    • Chrome 17 is not clearing is not clearing placeholder text on focus event

Will try to submit this as WebKit bug...

Owner

mathiasbynens commented Feb 9, 2012

That’s how Chrome handles placeholder now. Safari has the same behavior. This has nothing to do with the plugin, as the plugin won’t do anything in case the browser natively supports placeholder.

OMG you are fast :)

Could you provide some info about that please? I tried googling around but have failed.

So making webkit browser behave as others will require some workaround. I guess i will have to tell client that this is how webkit works now and "no" workaround is possible... ;D

Owner

mathiasbynens commented Feb 9, 2012

Well, a workaround is possible, but you’d have to remove the placeholder attribute and fake it yourself (possibly by using a modified version of this plugin).

Here’s the commit from two months ago: http://trac.webkit.org/changeset/101848 (This is for Chrome; Safari has had it for a while now.)

Yeah, i know it's possible, but, like you said, that requires faking it... =D

Thanks Mathias! You are the best! Looking forward @ http://2012.front-trends.com =D

Owner

mathiasbynens commented Feb 9, 2012

Oh cool, you’ll be there too! Come say hi! :)

bruha commented Feb 27, 2012

You can add this to the end of file to fix Webkit:

// Fixing Webkit that not clearing input/textarea when get focus
$(function(){
if ($.browser.webkit) {
$('input, textarea').on('focus',function(){
if ( $(this).attr('placeholder') ) $(this).data('placeholder', $(this).attr('placeholder')).removeAttr('placeholder');
}).on('blur', function(){
if ( $(this).data('placeholder') ) $(this).attr('placeholder', $(this).data('placeholder')).removeData('placeholder');
});
}
});

bmamlin commented Mar 5, 2012

I see this as a bug in Firefox; Chrome & Safari handle placeholders properly. Clearing out the placeholder on focus removes the placeholder when it's most needed. Looking for a plugin that will address this Firefox bug...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment