Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Add mouse up down event support #308

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

matthew-andrews
Copy link
Contributor

Replacement pr for #289

@matthew-andrews
Copy link
Contributor Author

@rowanbeentje can you sanity check+merge?

@rowanbeentje
Copy link
Contributor

Sanity checks - seems fine.

Going through the browsers, it seems Blackberry OS 2 will have a problem with this; there, mousedown is fired before touchend, so I think we'd get doubled-up events. Global usage is rather small, and OS 10 fixed the problem - worth adding a hack, or do we see this as the overall big fix it is anyway? :)

@matthew-andrews
Copy link
Contributor Author

Curses. Blackberry OS2. Is that a playbook?

@rowanbeentje
Copy link
Contributor

Yeah - the PlayBook and possibly the not-so-popular phones...

@MattMenchaca
Copy link

Mousedown is incorrectly triggered after blur. My use case is an autosuggestion drop-down.

Proof of concept code:

<body>
    <input type="text">
    <button>Click me</button>

    <script>
        FastClick.attach(document.body);

        $('input').blur(function() {
            alert('blur');
        }).focus();

        $('button').mousedown(function() {
            alert('mousedown');
        });
    </script>
</body>

@matthew-andrews
Copy link
Contributor Author

@MattMenchaca is that in relation to this branch?

@MattMenchaca
Copy link

I figured that this was the place to address it since it is related to the mousedown functionality this PR intends to support.

Here are some practical examples of this issue

  1. This PR would not allow users the ability to interact with a widget without losing focus on its related input and potentially hiding the widget. For instance, a date-picker widget Unable to use FastClick with Pikaday Pikaday/Pikaday#133
  2. Imagine a custom drop-down interface, not unlike a normal <select>. In this example, the drop-down is hidden when the input blurs and an 'option' is chosen when a user mousesdown on the list. Even though the list is hidden first, the mousedown event still occurs on the correct target. Thus, the issue of event order may go unnoticed.
  3. In the case of my autosuggestion widget, the suggestion list is dynamically loaded via AJAX and emptied on blur. In this case, by the time the mousedown event fires, its target no longer exists. I was able to work around this issue by changing when the list is cleared (before new suggestions are shown instead of when the widget is hidden).

@njam
Copy link

njam commented Dec 16, 2014

@MattMenchaca isn't this also the case with the click event currently synthesized by FastClick? If you bind blur and click according to your example above you'll get blur -> click with FastClick but click -> blur without it. I understand you don't want the same to happen with mousedown, because you rely on it firing before blur.

It seems it boils down to a trade-off between that some libraries require mousedown to be fired, and others expect mousedown to be fired before blur.

I'd vote to add mousedown synthesis because I think it's more consistent and supports more use cases.
Also as you mentioned most use cases will still work, because the mousedown on the target element is still triggerd, even after the element might have been hidden (because of blur).

@ArthurClemens
Copy link

It's a pity that this hasn't been integrated yet.

@atom-project
Copy link

please merge this...

@gingters
Copy link

Yes, please merge this, as I also need this. Fastclick breaks some other components, i.e. typeahead and select2 when active without that.

@cnole
Copy link

cnole commented Feb 10, 2016

Please merge this, i also need this for our tracking library which relies on "mousedown".

@JonathanKolnik
Copy link

Please merge this

@landabaso
Copy link

FastClick also breaks the Button component of react-toolbox, which also relies on onMouseUp events.
+1 to merge this PR. Thanks!

@musicformellons
Copy link

Please merge yesterday.

@dpeacock
Copy link

This fixed my issue with fastclick and select2, would like to see this merged in too.

@brianarpie
Copy link

Please merge this, it fixed fastclick for my react-quill / quilljs rich text editor.

@JakeChampion
Copy link
Contributor

@rowanbeentje Are we still aiming to support BlackBerry OS2?

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

Successfully merging this pull request may close these issues.

None yet