product and sales fixers
This commit is contained in:
@@ -22,6 +22,9 @@ export interface ScanInputProps {
|
||||
hint?: string
|
||||
placeholder?: string
|
||||
disabled?: boolean
|
||||
/** Grab focus on mount/re-enable (default true). Turn off when another field on the page
|
||||
* should get the cursor first (e.g. a type-ahead "Add item" box). */
|
||||
autoFocus?: boolean
|
||||
className?: string
|
||||
}
|
||||
|
||||
@@ -31,6 +34,7 @@ export function ScanInput({
|
||||
hint = "Scan item or lot barcode",
|
||||
placeholder = "Scan or type a barcode, then press Enter",
|
||||
disabled = false,
|
||||
autoFocus = true,
|
||||
className,
|
||||
}: ScanInputProps) {
|
||||
const [value, setValue] = useState("")
|
||||
@@ -39,8 +43,8 @@ export function ScanInput({
|
||||
// Refocus whenever the field becomes usable again (e.g. after being briefly disabled while a
|
||||
// lookup for the previous scan was in flight) so a scanner's next read always lands here.
|
||||
useEffect(() => {
|
||||
if (!disabled) inputRef.current?.focus()
|
||||
}, [disabled])
|
||||
if (!disabled && autoFocus) inputRef.current?.focus()
|
||||
}, [disabled, autoFocus])
|
||||
|
||||
function commit() {
|
||||
const code = value.trim()
|
||||
|
||||
Reference in New Issue
Block a user