Skip to content

Commit 170e4f1

Browse files
authored
Merge pull request #315 from getmaxun/cuslim-fix
fix: update custom limit if value >= 1
2 parents 222cc63 + af237ba commit 170e4f1

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/components/organisms/RightSidePanel.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,22 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
529529
<TextField
530530
type="number"
531531
value={customLimit}
532-
onChange={(e) => updateCustomLimit(e.target.value)}
532+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
533+
const value = parseInt(e.target.value);
534+
// Only update if the value is greater than or equal to 1 or if the field is empty
535+
if (e.target.value === '' || value >= 1) {
536+
updateCustomLimit(e.target.value);
537+
}
538+
}}
539+
inputProps={{
540+
min: 1,
541+
onKeyPress: (e: React.KeyboardEvent<HTMLInputElement>) => {
542+
const value = (e.target as HTMLInputElement).value + e.key;
543+
if (parseInt(value) < 1) {
544+
e.preventDefault();
545+
}
546+
}
547+
}}
533548
placeholder={t('right_panel.limit.enter_number')}
534549
sx={{
535550
marginLeft: '10px',

0 commit comments

Comments
 (0)