mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-27 11:12:55 +00:00
Fix pasting the device code not working
This commit is contained in:
@@ -318,12 +318,28 @@ export default function DeviceLoginForm({
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<div className="flex justify-center">
|
<div className="flex justify-center">
|
||||||
<InputOTP
|
<InputOTP
|
||||||
maxLength={9}
|
maxLength={8}
|
||||||
pattern={REGEXP_ONLY_DIGITS_AND_CHARS}
|
pattern={REGEXP_ONLY_DIGITS_AND_CHARS}
|
||||||
{...field}
|
{...field}
|
||||||
value={field.value
|
value={field.value
|
||||||
.replace(/-/g, "")
|
.replace(/-/g, "")
|
||||||
.toUpperCase()}
|
.toUpperCase()}
|
||||||
|
onPaste={(event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
const pastedText =
|
||||||
|
event.clipboardData.getData(
|
||||||
|
"text"
|
||||||
|
);
|
||||||
|
const cleanedValue =
|
||||||
|
pastedText
|
||||||
|
.replace(
|
||||||
|
/[^a-zA-Z0-9]/g,
|
||||||
|
""
|
||||||
|
)
|
||||||
|
.toUpperCase()
|
||||||
|
.slice(0, 8);
|
||||||
|
field.onChange(cleanedValue);
|
||||||
|
}}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
// Strip hyphens and convert to uppercase
|
// Strip hyphens and convert to uppercase
|
||||||
const cleanedValue = value
|
const cleanedValue = value
|
||||||
|
|||||||
Reference in New Issue
Block a user