-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve placeholder text on focus #209
Conversation
This will make it easier to override them in a way that applies to both regular inputs and passwords.
To trigger the feature, call the placeholder plugin with an object that sets a preserveOnFocus property to true. Real documentation coming after I fix a couple issues with cursor placement.
This also makes some attempt to prevent selecting placeholder text by repositioning the caret on clicks. Additionally, options now extend a settings object that is available throughout the whole plugin.
By attempting to reset the placeholder text on keyup, the placeholder text will re-appear if you use backspace to clear a form field.
@mlms13 seems like a good thing to have. The code has fallen behind. Also, we don't need an option, it should be the default setting. All modern browsers (except ie 10/11) behave this way (they preserve the placeholder on focus). Can you please update? Thanks. |
@mlms13 ping |
Hey, I'm about to jump on a plane. I'll see if I have a chance to make your suggested changes then. I'm excited the library is being maintaned again. :) |
Conflicts: README.md jquery.placeholder.js
Per the comments in the pull request, the new behavior should be the default. All modern browsers choose to leave the placeholder text until you start typing, so jquery.placeholder will emulate that behavior.
It should be up-to-date now, but I haven't tested it since merging master into this branch. I'll run it in some browsers on Monday to make sure it still behaves as expected. |
@mlms13 Were you able to solve this? |
Just fixed a typo that was causing the grunt build to fail. I tested in IE8 and IE9, and as far as I can tell, everything looks ok to me. |
@mlms13 I haven't had time to test it yet, but I do see you use |
Tested on IE11 and nothing, it still disappeares |
@gabskoro I don't think the jquery-placeholder plugin polyfills IE11, because it natively supports the |
Looks like my branch is conflicting again. I'm happy to keep it up to date if there's a chance that this will be merged. |
If a user pastes some text by the This feature needs an event like |
@Alex1990 ... ignore my original comment... I got it now. Yes, since we're no longer targeting focus, we need more intelligent ways to figure out if the input contains text. @amerikan If there's anything else I need to do, feel free to add it to this checklist.
I'm not including the request to override IE 10's behavior, because that seems like a bigger issue that changes the behavior of this plugin (ie feature detection will no longer be enough)... a bit outside of the scope of this PR. |
If anyone is still interested in this feature, my fork is up to date with the latest changes. It hasn't been tested recently, and it looks like a weird merge happened with the |
@mlms13 I believe this PR got automatically closed because the |
Ah, makes sense. I'll try to fix up the weirdness I'm seeing in the |
This series of commits gives the plugin the option to behave more like the placeholder implementation in Chrome and Firefox. Placeholder text remains visible until characters are entered into the input. See #92 for more info.