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

Dropdown repeatly shows options under label element #3917

Closed
MohanVijayakumar opened this issue Apr 9, 2016 · 7 comments
Closed

Dropdown repeatly shows options under label element #3917

MohanVijayakumar opened this issue Apr 9, 2016 · 7 comments
Milestone

Comments

@MohanVijayakumar
Copy link

when the dropdwon placed inside label (inline) element , the dropdown options shows repeatedly

http://jsfiddle.net/cdr0hvhz/1/

@jlukic jlukic added this to the 2.2.x milestone Apr 13, 2016
@DataTables
Copy link

I've just been looking into this as it was reported to me for my DataTables integration with Semantic UI as well.

I think a small modification to @MohanVijayakumar's Fiddle shows the issue: http://jsfiddle.net/cdr0hvhz/3/ . Basically what is happening is that a click on the text in the label is triggering the click event on the label dropping the code into eventInModule. So eventInModule is actually called twice while the Semantic UI menu is open - the click on the div of options and another (the issue) on the select element coming from the text.

So the listener for the label needs to detect if the dropdown is shown or not before doing anything.

Removing .on('click' + eventNamespace, selector.item, module.event.item.click) appears to address the issue and I don't see any side-effects, but I doubt that is the answer - it doesn't feel right!

@jlukic
Copy link
Member

jlukic commented May 2, 2016

I'll try to take a look at this when i get a chance.

@vincent-olivert-riera
Copy link

vincent-olivert-riera commented May 5, 2016

I was experiencing this issue and I didn't know it was already reported. Thanks @jlukic to look into it, I hope you fix it soon.

@MohanVijayakumar
Copy link
Author

I got the same problem when using datatable.
here is the temp solution which is i used for this issue.
find the lable element and get the child content of that and replace the label element with div element add the contents under div element

var dt_lengthParent = $('[name="id_tbl_assignedmaterialitems_length"]').closest('label'); var dt_pagelengthHolder = dt_lengthParent.contents(); dt_lengthParent.replaceWith( '<div id="id_tbl_assignedmaterialitems_length_con_div"></div>'); $('#id_tbl_assignedmaterialitems_length_con_div').append(dt_pagelengthHolder);

@jlukic jlukic modified the milestones: 2.2, 2.2.x May 12, 2016
@jlukic
Copy link
Member

jlukic commented May 15, 2016

It's simple enough to fix this by adding

  $('label')
    .on('click', function(event){
      event.preventDefault();
    })
  ;

@jlukic
Copy link
Member

jlukic commented May 15, 2016

I've added a solve for determining if the event comes from a label click event on a surrounding label. This should prevent anyone having to add additional code outside of init like mentioned above.

Keep in mind the third example, label clicks should still trigger show correctly when not from a surrounding label.

Example from next
http://jsfiddle.net/La0sdpqd/

@jlukic jlukic closed this as completed May 15, 2016
@DataTables
Copy link

Awesome! Thank you very much :-)

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

No branches or pull requests

3 participants