Skip to content

Commit

Permalink
fix: trigger the onChange event of qr code uploading input when cli…
Browse files Browse the repository at this point in the history
…cking on the button (#1421)
  • Loading branch information
vardan-arm committed Aug 22, 2022
1 parent e7acbd7 commit 2a976a0
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ const convertToGrayScale = (imageData) => {
}

export default class QRCodeReader extends React.Component {
constructor() {
super()

this.fileInputRef = React.createRef(null)
}

onImageSelected = (evt) => {
const file = evt.target.files[0]
const url = URL.createObjectURL(file)
Expand Down Expand Up @@ -70,9 +76,9 @@ export default class QRCodeReader extends React.Component {
render() {
return (
<div className="qr-code-reader-container">
<div className="sk-button info">
<div className="sk-button info" onClick={() => this.fileInputRef.current.click()}>
<div className="sk-label">Upload QR Code</div>
<input type="file" style={{ display: 'none' }} onChange={this.onImageSelected} />
<input type="file" style={{ display: 'none' }} ref={this.fileInputRef} onChange={this.onImageSelected} />
</div>
</div>
)
Expand Down

0 comments on commit 2a976a0

Please sign in to comment.