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

<select> inside a <label> #253

Closed
Korri opened this issue Nov 18, 2014 · 4 comments
Closed

<select> inside a <label> #253

Korri opened this issue Nov 18, 2014 · 4 comments

Comments

@Korri
Copy link
Contributor

Korri commented Nov 18, 2014

On our website we had a few selects embed inside a label.

When you click the label it is supposed to focus the dropdown, but right now it doesn't do anything and worse, it prevents the dropkick from opening has it triggers a click event on the underlying , and then closes all the open dropkicks.

@wwilsman
Copy link
Collaborator

I've ran into this problem in the past, but forgot to open an issue on it. I eventually ended up refactoring my code to use the 'for' attribute on labels (and not nesting the select). The only solution to nesting inside of a label that I can think of would be to check if a dropkick element has an ancestor label and then opening the dropkick element when that label is clicked. This could get costly to check each ancestor on every document click to determine if there's a label and then if that label contains a dropkick element. A solution to that would be to perform the check on initialization and add a handler to any ancestor labels. However, programmatically adding labels or removing nested elements would require rebinding the handlers manually or recalling the initialization method.

Forget everything I just said. I went and did some testing and found that when you click on a label it triggers a second event from it's control element. A simple check to ignore this click makes the dropkick work as intended.

If you, or anyone can suggest more elegant solutions, or do tests to determine if the costliness of that check on every document click would be minimal, please feel free reply with your suggestion or results and I'll have it implemented asap.

@wwilsman
Copy link
Collaborator

I've edited my previous answer because I found a solution and will push it once I fix a similar issue with ancestor labels not focusing the dropkick element.

wwilsman added a commit that referenced this issue Nov 18, 2014
@wwilsman
Copy link
Collaborator

Check out develop to see if this fixes your issue.

@Korri
Copy link
Contributor Author

Korri commented Nov 19, 2014

Yep, works as expected now, awesome !

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