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

Double click to open, single click to outside blur #23

Closed
jenstornell opened this issue Jan 22, 2019 · 3 comments
Closed

Double click to open, single click to outside blur #23

jenstornell opened this issue Jan 22, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@jenstornell
Copy link

jenstornell commented Jan 22, 2019

I've changed the dropdown example and added an event. In this case I double click to open the dropdown, so far so good. When I click outside nothing happends because I need to double click outside to make it hide again.

In my case I want to double click to open and single click to hide. Is that possible or do I need to roll out an own solution? Or a hook for it?

https://twikito.github.io/easy-toggle-state/#dropdown

<div class="example-dropdown">
	<button type="button"
		class="example-dropdown-button"
		data-toggle-class="is-open"
		data-toggle-target-next
                data-toggle-event="dblclick"
		data-toggle-outside
		data-toggle-escape>
		Select something here
	</button>
	<ul class="example-dropdown-list">
		<li>
			<button type="button">Lorem ipsum dolor</button>
		</li>
		<!-- Several options -->
	</ul>
</div>

Feature

A possible feature would be data-toggle-outside-event to specify a special event for outside clicks.

Hack it

For anyone else having this issue, it's possible to fix it by hacking the code like this:

Go here:

https://github.com/Twikito/easy-toggle-state/blob/master/dist/easy-toggle-state.es6.js#L188

Change it to:

if (target.hasAttribute(OUTSIDE) && target.isToggleActive) {
  document.addEventListener("click", documentEventHandler, false);
}
@Twikito
Copy link
Owner

Twikito commented Jan 22, 2019

Hi!
Thanks for taking time to report this issue.

I assumed the event would be always the same to toggle on and off, but I see with you case study that it not true. So yes, I think a new attribute data-toggle-outside-event would be great for you.

@Twikito Twikito added the enhancement New feature or request label Jan 22, 2019
@Twikito
Copy link
Owner

Twikito commented Jan 24, 2019

Ok @jenstornell, I add a new data-toggle-outside-event attribute. Can you tell me if it works for you?

Doc here: https://twikito.github.io/easy-toggle-state/#advanced.

@jenstornell
Copy link
Author

Tested it out quickly and it works just like expected. Well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants