question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clicking label does not activate text input

See original GitHub issue

I am using ruby on rails with Materialize Gem I am working on signup/sign-in form in Model The problem is with password text field .when clicked on password label active class is not added but work fine with other input fields can’t see any issue in java-script . Inputs do not activate when clicking the label. You need to click below the label to active.

Rendered Html Output

`<form class="new_user" id="new_user" action="/signup" accept-charset="UTF-8" method="post">

<div class="row"> <div class="col s12 center-align"> wc <label for="user_gender_male">Male</label> <label for="user_gender_female">Female</label> </div> </div> <div class="row"> <div class="input-field col s12 m6"> account_circle <label for="user_user_name">Name</label> </div> <div class="input-field col s12 m6"> date_range <label for="user_dob">Birthday</label> </div> </div> <div class="row"> <div class="input-field col s12 m6"> lock_outline <label for="user_password">Password</label> </div> <div class="input-field col s12 m6"> lock_outline <label for="user_password_confirmation">Password confirmation</label> </div> </div> <div class="row"> <div class="input-field col s12 m6"> assignment_ind <label for="user_email">Email</label> </div> <div class="input-field col s12 m6"> phone <label for="user_phone_number">Phone number</label> </div> </div> <div class="row"> <div class="col s12"> </div> </div> </form>`

Any Help Will be Welcomed.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

21reactions
kmmbvnrcommented, Nov 2, 2016

You have wrong id in the <label for=" attribute.

<input id="user_password2" ...
<label for="user_password" ...

Check the:

https://codepen.io/kmmbvnr/pen/dObyzM?editors=1000#0

Labels works fine.

6reactions
jessenieminencommented, Nov 1, 2016

I’ve had the same problem but was able to monkeypatch that quite easily with the help of css pointer-events.

Just adding the following piece of less code did the trick for me. If you’re not using less, the actual code will of course differ for you but the basic principle stays the same.

/* Clicking the label does not activate the input without this */
input[type="text"] + label {
    pointer-events: none;

    * {
        pointer-events: all;
    }
}

Having said that, I think this should definitely be fixed directly to Materialize.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clicking label doesn't check my input field - Stack Overflow
1 Answer. Save this answer. Show activity on this post. You'll have to assign the label to the correct input, so either use...
Read more >
28657 - Clicking on <LABEL> doesn't put focus in INPUT field
Try clicking on a label associated with a form field in IE. It passes focus to the field. Even if this wasn't standard...
Read more >
Clicking on label input file does'nt work - WordPress.org
Hello, I want to style an input file created with forminator in css. To achieve this, the main solution is to hide the...
Read more >
How to activate or focus an input HTML element when clicking ...
As you can see from the above GIF that when clicking on the label HTML element the input HTML element is not getting...
Read more >
Input Label not clickable - remains in the field - MDBootstrap
The Label (inactive) keeps me from clicking into the input box if I click on the ... username, password and password2 do not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found