question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Browser elements should respond to click events

See original GitHub issue

The <FastClick> component wraps every other component in the codebase that handles user interaction in the browser. Ironically, this component does not actually support click events! It supports mousedown and touchstart/touchend, but click events are swallowed and ignored.

Not all users use a mouse or a touchscreen. If a user tries to navigate the website using a keyboard (or an assistive tech device that emulates a keyboard), the user will be totally unable to use Searchkit. (Keyboards can send click events by focusing on a clickable element like a <button>, and pressing spacebar.) In order to be accessible, Searchkit needs to support keyboard use.

I see two ways of addressing this issue: removing the <FastClick> component entirely, or making it support click events. I’m not sure which approach is better, but I’d like to start the discussion. Why does the <FastClick> component exist? Why is it specifically designed to swallow and ignore click events?

This is related to #359 (accessibility).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:17 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
singingwolfboycommented, Mar 14, 2017

How would FastClick be able to reliably determine if there was an event dispatched by mousedown, when deciding whether or not to swallow a click event? If your concern is about performance, I would expect that holding on to prior events is going to cause a performance penalty.

There’s also a nice usability perk that comes from using the click event instead of the mousedown event – the user can mousedown on an element, change their mind, move the mouse off the element, and then release the mouse in order to cancel the impending event. It’s a little thing, but it’s a bit disappointing that you can’t do that with the way you’ve implemented FastClick.

I guess my question is, why is speed so important in this case? I agree that performance is an important metric, but not to the extent that it negates others like usability and accessibility.

1reaction
ssetemcommented, May 9, 2017

right at beginning of your code, something alone these lines

import {FastClick} from "searchkit"

FastClick.prototype.render = function(){
  return React.cloneElement(this.props.children, {
    onClick:this.props.handler
  })
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Element: click event - Web APIs | MDN
An element receives a click event when a pointing device button (such as a mouse's primary mouse button) is both pressed and released...
Read more >
Introduction to browser events - The Modern JavaScript Tutorial
Mouse events : click – when the mouse clicks on an element (touchscreen devices generate it on a tap). · Keyboard events: keydown...
Read more >
How does the browser know which element should get a click ...
If I click on the link, the browser knows to execute all click events attached to that link.
Read more >
Event Handling with Event Handler Properties
Each event has a name, like 'click' or 'scroll', and belongs to a specific object, like document (our HTML) or window (our browser...
Read more >
Browser Events Explained in Plain English - freeCodeCamp
In the example below, if you click the element with id btn , event.target will reference it. All click event handlers are passed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found