diff --git a/components/lib/inputotp/InputOtp.js b/components/lib/inputotp/InputOtp.js index 16af969df4..9e0d8e3804 100644 --- a/components/lib/inputotp/InputOtp.js +++ b/components/lib/inputotp/InputOtp.js @@ -79,6 +79,10 @@ export const InputOtp = React.memo( }; const onInput = (event, index) => { + if (props.disabled || props.readOnly) { + return; + } + if (event.nativeEvent.inputType === 'insertFromPaste') { return; // handled in onPaste } @@ -93,6 +97,10 @@ export const InputOtp = React.memo( }; const onPaste = (event) => { + if (props.disabled || props.readOnly) { + return; + } + let paste = event.clipboardData.getData('text'); if (paste.length) { @@ -117,6 +125,15 @@ export const InputOtp = React.memo( }; const onKeydown = (event) => { + if (props.disabled || props.readOnly) { + return; + } + + // special keys should be ignored, if it is CTRL+V is handled in onPaste + if (event.altKey || event.ctrlKey || event.metaKey) { + return; + } + switch (event.code) { case 'ArrowLeft': { moveToPrevInput(event);