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

Added posibility to scan barcodes on input #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Test extends Component {
| stopPropagation | bool | false | Stop immediate propagation on keypress event
| preventDefault | bool | false | Prevent default action on keypress event
| testCode | string | | Test string for simulating
| preventScanOnInput | bool | true | Prevents input from being read at the input, textarea, and other editable areas.

## Dev

Expand Down
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ class BarcodeScanner extends React.Component {

handleKeyPress = (e) => {
const {
onKeyDetect, onReceive, scanButtonKeyCode, stopPropagation, preventDefault, endChar, startChar, timeBeforeScanTest,
onKeyDetect, onReceive, scanButtonKeyCode, stopPropagation, preventDefault, endChar, startChar, timeBeforeScanTest, preventScanOnInput
} = this.props

const { target } = e

if (target instanceof window.HTMLElement && isInput(target)) {
if (preventScanOnInput && target instanceof window.HTMLElement && isInput(target)) {
return
}

Expand Down Expand Up @@ -173,6 +173,7 @@ BarcodeScanner.propTypes = {
stopPropagation: PropTypes.bool, // Stop immediate propagation on keypress event
preventDefault: PropTypes.bool, // Prevent default action on keypress event
testCode: PropTypes.string, // Test string for simulating
preventScanOnInput: PropTypes.bool, // Prevents input from being read at the input, text area, and other editable areas.
}

BarcodeScanner.defaultProps = {
Expand All @@ -184,6 +185,7 @@ BarcodeScanner.defaultProps = {
scanButtonLongPressThreshold: 3,
stopPropagation: false,
preventDefault: false,
preventScanOnInput: true,
}

export default BarcodeScanner