这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@hugofelp
Copy link
Contributor

@hugofelp hugofelp commented Jan 9, 2015

relates to:
#40
#265

First of all, thanks for this great plugin.
The two bugs above are caused by a label tag wrapping the input field. They have been flagged as invalid, but as I must disagree, as it is valid and semantic html.

@starise
Copy link

starise commented Apr 4, 2016

Fix this would be very appreciated.

@DanielRuf
Copy link
Contributor

.off can be chained with .on

@DanielRuf
Copy link
Contributor

DanielRuf commented Feb 24, 2018

Also I guess stopPropagation, stopImmediatePropagation and preventDefault are the right solution.

@hugofelp
Copy link
Contributor Author

hugofelp commented Feb 25, 2018

Hi @DanielRuf
Thanks for your response.

I think chaining off and on would end up adding the event listener back too early, in the same cycle, while the event is still alive. That is why there is a setTimeout between them.

And I think this solution may be less intrusive than stopping the propagation of the event, as the event could still be used by other parts of an application. Probably an important consideration for a library.

Please have in mind that this PR is more than three years old, and I am talking from memory here. Don't take my word without running tests yourself ;)

@DanielRuf
Copy link
Contributor

Merging for now but may need some small changes.

@DanielRuf DanielRuf merged commit 35b6d8a into amsul:master Mar 1, 2018
@pixelmachine
Copy link

pixelmachine commented Mar 9, 2018

@DanielRuf this merge seems to give me an error:
ReferenceError: Can't find variable: focusToOpen

If the input is in a label the picker can't be closed, if a container is specified the error still occurs though it will close as expected.

@DanielRuf
Copy link
Contributor

Ah I see. Missed that. I guess it should be handleFocusToOpenEvent?

@pixelmachine
Copy link

Yeah. That kills the error but doesn't allow an input to work inside a label.

@pixelmachine
Copy link

I see the problem actually:
$ELEMENT.off('click.' + STATE.id)
Should be
$ELEMENT.off('.' + STATE.id)
That seems to work correctly in my quick test.

@pixelmachine
Copy link

Along with:
$ELEMENT.on('click.' + STATE.id, focusToOpen)
Should be:
$ELEMENT.on('click.' + STATE.id, handleFocusToOpenEvent)

@DanielRuf
Copy link
Contributor

Do you want to provide a PR? That would be very helpful.

@pixelmachine pixelmachine mentioned this pull request Mar 9, 2018
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

Successfully merging this pull request may close these issues.

4 participants