Skip to content
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

Auto-selecting readonly fields?.. or as-is? #68

Closed
METACEO opened this issue Jan 31, 2016 · 1 comment
Closed

Auto-selecting readonly fields?.. or as-is? #68

METACEO opened this issue Jan 31, 2016 · 1 comment

Comments

@METACEO
Copy link

METACEO commented Jan 31, 2016

This will auto-select the contents of fields the user is supposed to copy from (if the browser is in-compatible then this should still gracefully pass.) Is this PR worthy or will everything be left as-is and nothing more?

function focusOnReadonlyFields(e){
    // IF it's readonly AND a selectable.
    if(e.target.hasAttribute("readonly") && typeof e.target.select === "function"){

        // IF it's what we intend.
        if(e.target.tagName === "TEXTAREA" || (
            e.target.tagName === "INPUT" &&
            e.target.getAttribute("type") === "text"
        )){
            e.target.select();
        }
    }
}
document.getElementById("body").addEventListener("click", focusOnReadonlyFields);

(Just certified my first Let's Encrypt site with the help of gethttpsforfree, awesome work!)

@diafygi
Copy link
Owner

diafygi commented Feb 22, 2016

Eh, not wild about messing with selection mechanics. I usually find it annoying when another website doesn't let me select stuff as I please.

@diafygi diafygi closed this as completed Feb 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants