enter key chains through the battery S/N fields

This commit is contained in:
Yinyin Liu 2026-04-13 10:38:18 +02:00
parent 1ccdcca21a
commit 18d47232b7
1 changed files with 19 additions and 0 deletions

View File

@ -1020,11 +1020,30 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
{Array.from({ length: batteryCount }, (_, batIdx) => (
<TextField
key={`bat-${invIdx}-${clIdx}-${batIdx}`}
id={`bat-${invIdx}-${clIdx}-${batIdx}`}
label={intl.formatMessage({ id: 'batteryNSerialNumber', defaultMessage: 'Battery {n} Serial Number' }, { n: batIdx + 1 })}
value={batterySnTree[invIdx]?.[clIdx]?.[batIdx] || ''}
onChange={(e) =>
handleBatterySnTreeChange(invIdx, clIdx, batIdx, e.target.value)
}
onKeyDown={(e) => {
if (e.key === 'Enter' && presetConfig) {
e.preventDefault();
let nextInv = invIdx, nextCl = clIdx, nextBat = batIdx + 1;
if (nextBat >= presetConfig[invIdx][clIdx]) {
nextBat = 0;
nextCl = clIdx + 1;
if (nextCl >= presetConfig[invIdx].length) {
nextCl = 0;
nextInv = invIdx + 1;
if (nextInv >= presetConfig.length) return;
}
}
const nextId = `bat-${nextInv}-${nextCl}-${nextBat}`;
const nextInput = document.getElementById(nextId) as HTMLInputElement | null;
if (nextInput) nextInput.focus();
}
}}
variant="outlined"
fullWidth
placeholder={canEdit ? 'Scan or enter serial number' : ''}