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.

Change how to prevent default events

See original GitHub issue

Right now if you add a custom event handler (like onKeyDown to the getInputProps for example), you can prevent the default behavior with event.preventDefault(). This has worked pretty well, but honestly it’s overloading the feature of preventing the default from events so we should come up with another way to signal preventing the default behavior.

What if instead you simply add a property to the event like: event.preventDownshiftDefault = true and then downshift references that rather than event.defaultPrevented?

I think that’d be pretty simple and straightforward and the upgrade for this breaking change would be pretty smooth. In fact, we could support both for a little while without much trouble.

Thoughts?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
pcattoricommented, Apr 14, 2018

@kimgronqvist you missed a pair of {} to destructure onKeyDown from getInputProps 😛 :

const { onKeyDown } = getInputProps();

link with the fix

thanks!

1reaction
k-odecommented, Apr 14, 2018

Sure! This example conveys the general idea: https://codesandbox.io/s/zx9z9275xm

Read more comments on GitHub >

github_iconTop Results From Across the Web

Event.preventDefault() - Web APIs | MDN
The preventDefault() method of the Event interface tells the user agent that if the event does not get explicitly handled, its default ...
Read more >
javascript - preventDefault() not working for change event
By using evt.preventDefault(evt) inside a click event you can stop the default behaviour so that you can do other operations before you action ......
Read more >
preventDefault() Event Method
The preventDefault() method cancels the event if it is cancelable, meaning that the default action that belongs to the event will not occur....
Read more >
event.preventDefault() | jQuery API Documentation
event.preventDefault()Returns: undefined. Description: If this method is called, the default action of the event will not be triggered.
Read more >
How to Manage Browser Defaults with event. ...
This method prevents default actions that browsers make when an event is triggered. Here are some examples of default actions on webpages and ......
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