mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-15 11:04:49 +00:00
utils/react: add preventDefault helpers
These can be used instead of always having to add a comment explaining what preventDefault does in a given context.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
// helper functions for React components
|
||||
|
||||
import React from 'react';
|
||||
|
||||
/**
|
||||
* Callback that can be passed to onMouseDown event handlers to prevent
|
||||
* an element from becoming focused when clicked.
|
||||
*/
|
||||
export const preventFocusOnClick: React.MouseEventHandler = (e) => e.preventDefault();
|
||||
|
||||
/**
|
||||
* Callback that can be passed to onContextMenu event handlers to prevent
|
||||
* the native browser context menu from being shown.
|
||||
*/
|
||||
export const preventBrowserNativeContextMenu: React.MouseEventHandler = (e) =>
|
||||
e.preventDefault();
|
||||
Reference in New Issue
Block a user